New Game Protocol:
# This is the protocol for starting a game
PLAYER 2 <- indicates which position around the table you are sitting
as 2s 3s 4s 5s ... <- your hand
# Eventually we should have a player choose a game - that should happen here.
GAMENAME <- name of the game
# Each player gets a chance to double. Slightly different than actual
# barbu, you only get a chance to double once, if you are doubled after
# then you do not get another chance to re-double.
1 DOUBLE 2 0
3 DOUBLE 0
0 DOUBLE 3
# This is the protocol for trick-taking games
# (nullo, queens, barbu, hearts, last two, ravage, trumps)
TRICK <- indicates that we're starting a trick
PLAY <- PLAY reminds you that it's your turn to play
kh <- if this is barbu then the game is over
# This is the protocol for dominoes
# This is the protocol for ending a game
END 0 0 0 -18
Cards are specified as two character strings, the first character is rank and the second character is suit.
Ranks are 23456789tjqka
Suids are cdhs
kh - king of hearts
as - ace of spades
2d - two of diamonds
An Ai is first given the name of the game on a single line, current games right now are RAVAGE and LASTTWO.
After the game is specified the ai will be given its hand on a single line, 13 cards each separated by a space.
3h 6s 9c ks 2h kc td qd 5d 6h jh kh jd
After that will be 13 rounds, each round goes as follows:
The ai will receive a list of cards on a single line, each separated by a space. These are the cards played by the other players so far this trick. The cards are listed in the order they are played, so if the line is
that means the player across from this ai lead with the king of clubs, the player to this ai's right played the ace of clubs, and now it is this ai's turn to play.
This ai should write the card it wants to play to stdout, followed by a newline.
After this the ai will receive a list of cards on a single line, each separated by a space. These are the cards played by the rest of the players this trick. The cards are listed in the order they are played.
An example of a few rounds:
Stdin > 4s ks as
Stdin > 8h
Stdin > 4h 6h
In this example there are two tricks. This ai was last to play in the first trick. The four of spades was lead and this ai followed with the nine of spades. Since this ai was last to play in the trick there are no cards listed after its play. Since the player to this ai's right won the trick it is the only one that plays before it in the second trick. It leads with the eight of hearts, this ai follows with the jack, and then the remaining two players' cards are given on the last line.
After the 13 rounds another round may begin just as this one did with the name of the game on a single line.
To build everything you'll need go and g++ installed. Then just run make.bash.
Here is something you might try to see how things work:
--game ravage \
--n 5 \
--player1 bin/jonai \
--player2 bin/jonai \
--player3 bin/davidai \