#Put your AI folder in folder ./ai
Please follow this link
Start the game by running SixNimmt.py
and feed the path to the AIs that you
want to use for the game.
python SixNimmt.py ai/example/exampleai.py ai/example/exampleai.py
There's a fast way to use the same AI for more than once: prefix the number and
*
before the path.
python SixNimmt.py 2*ai/example/exampleai.py
The default mode is tournament mode. In this mode, the game will end as long as
a player reaches a certain score. The default value of this score is 100, and
you can change it by passing the value to --score
or -s
argument.
python SixNimmt.py 2*ai/example/exampleai.py -s 300
There's another mode called official mode. In this mode, one set of cards is
generated and every player will receive every hand in this set once. This is
fairer than the tournament mode. You can set how many rounds you want to do
this by passing the value to --rounds
or -r
argument, the default
value is 1.
python SixNimmy.py 2*ai/example/exampleai/py -r 3
The random seed is generated randomly by default. However, if you want to use
the same seed for testing purpose, you can specify the seed you want to use
with --seed
argument. The game will behave the same if the seed is
specified.
python SixNimmy.py 2*ai/example/exampleai/py --seed 123
If you don't need the info to the stdout generated by the game, you can pass
--quiet
or -q
to get rid of it.
python SixNimmt.py 2*ai/example/exampleai.py -q
All the communications are by stdin and stdout.
Every packet from the game to the ai are in the following form:
<HEADER>|<SUBHEADER>|<DATA>
<HEADER>
could be either INFO or CMD. INFO requires no response from the AI
client, whereas CMD requires a single line of respose from stdout from the AI
client.
<SUBHEADER>
is the type of the request. It defines what kind of message the
game is sending.
<DATA>
is the corresponding data for <SUBHEADER>
, which will be explained below.
The detailed message type and data are listed in this section.
INFO|SETUP|<DATA>:
This is a initialization message for AI. <DATA>
is a dictionary with 2
keys(for now).
- "name": the official name you will have when you receive data in the future
- "playerNum": the total number of players
example:INFO|SETUP|{"name":"p1", "playerNum":2}
INFO|NEWGAME|<DATA>:
Send the signal that a new game is generated. <DATA>
is a list of cards that you
will start with. This packet is private to the players.
example:INFO|NEWGAME|[1,2,3,4,5,6,7,8,9,10]
INFO|GAME|<DATA>:
Send the info of the game data. This packet will be sent before every new round.
<DATA>
is a dictionary where there are 2 keys:
- "rows": a list of four lists, representing four rows of the current game
- "players": a dictionary of all the players, in which the key is the name of the player and the value is their score
example:INFO|GAME|{"rows":[[1],[2],[3],[4]],"players":{"p1":0, "p2":1}}
INFO|MOVE|<DATA>:
Send the info of a move of the round of all players. <DATA>
is a dictionary
where the keys are the players' names and the corresponding value is the cards
they play.
example: INFO|MOVE|{"p1":1, "p2":2}
INFO|SCORE|<DATA>:
Send the info of the score the player gets. This packet happens after a player
puts the sixth card of a row, or a player puts the smallest card and picks
a row from the game. <DATA>
is a dictionary where there are 3 keys:
- "player": the player that gets the score
- "cards": a list of cards the player gets
- "score": the total score the player gets
example:INFO|SCORE|{"player":"p1", "cards":[1,2], "score":2}
INFO|GAMEEND|<DATA>:
Send the info that the game ends. The program should quit when received this
message. <DATA>
is a dictionary with the final score.
example:INFO|GAMEEND|{"p1":105, "p2":78}
CMD|PICKCARD:
Request the player to pick a card from their hand. They response should be a number in stdout with '\n' in the end.
CMD|PICKROW:
Request the player to pick a row of the current game. This only happens if a player plays the smallest card among all players and the card is smaller than the smallest card of all the end card in rows. The response should be 0-3 with '\n' in the end.