2 stratego - Interface to manage games of stratego between AI programs and/or human players
5 This program is still a work in progress. Consider it a Beta version.
8 stratego {[-gpirb] [-o output_file ] [-t stall_time] [-m max_turns] {red_player blue_player | -f input_file} | {-h | --help} }
11 stratego manages a game of Stratego. It stores the state of the board, and uses a simple protocol to interface with AI programs.
12 By itself, stratego does not "play" the game. An external AI program must be used. stratego is intended to be used for the testing of
13 various AI strategies, written in any programming language. It will be used for the UCC Programming Competition 2012.
15 Unless the -h (--help) or -f switch is given, both red_player and blue_player must be supplied.
18 Should be either a path to an executable file which will control the Red player, or "human".
19 If set to "human", stratego will request the user to make moves for the Red player using stdin.
21 1. There is no plan to support AI programs named "human". Deal with it.
22 2. The graphical interface for human players is... basic. Deal with it.
25 As red_player, except for controlling the Blue player.
29 By default, graphics are disabled. If the -g switch is present, stratego will draw the game as it is played using SDL/OpenGL
32 By default, even if graphics are disabled, the board state is not printed. If -p is present, the board will be printed to stdout.
33 If the system supports colour, the characters will be in colour.
34 Yes, If -p and -g are both present you will see both behaviours (overkill)!
36 By default, stratego will exit if a move which is deemed "illegal" is made. If the -i switch is present, illegal moves will be ignored.
37 That is, the move will not be made (effectively the player making the illegal move loses a turn).
39 NOTE: If -i is not given and a human player accidentally(?) makes an illegal move, they will be asked to make a different move. The game will continue.
40 This is intended to prevent fits of rage due to the horrible graphical interface causing humans to make illegal moves.
42 By default, the identities of all pieces are shown. If the -r switch is present, and graphics are enabled, red pieces will be disguised.
43 If graphics are disabled, the -r switch has no effect.
45 Pieces which have previously taken part in combat (and survived) will be revealed.
47 As -r, except blue pieces will be disguised.
48 NOTE: Both -r and -b may be used together.
50 By default, stratego does not log moves. If the -o switch is present, the result of each move is printed to a file.
51 If output_file is "stdout" then stdout will be used instead of a text file.
53 By default, stratego executes moves as fast as they are recieved. If the -t switch is present, a delay of stall_time will be introduced
56 If stall_time is negative or "inf", stratego will wait for the user to press enter before moving to the next move.
58 It is tentatively planned to allow the user to enter various commands to alter the game or proceed to specified turns.
59 However this is slightly complicated. So it might never be done.
61 By default, the game is declared a Draw after 5000 turns have ellapsed.
62 Use this option to change the maximum number of turns.
63 To play for an infinite number of turns, supply "inf" as max_number. This is not recommended for obvious reasons.
66 By default, stratego requires red_player and blue_player to enact a game.
67 If this option is supplied, a file previously produced by using the -o switch is read, and the game reenacted.
68 All switches function as normal with -f.
69 NOTE: It is recommended that -g is used with -f.
72 If the -h switch is used, this page will be printed and stratego will exit.
77 Each player controls up to 40 pieces on the Board. The pieces consist of the following:
79 Piece Name Rank Number Abilities
80 1 Marshal 1 1 Dies if attacked by Spy
87 8 Miner 8 5 Destroys Bombs without being killed
88 9 Scout 9 8 May move more through multiple empty squares
89 s Spy 10 1 If the Spy attacks the Marshal, the Marshal dies
90 B Bomb NA 6 Immobile. If any piece (except a Miner) encounters an enemy Bomb, both pieces are destroyed
91 F Flag NA 1 Immobile. If any piece encounters the enemy Flag, the controlling player wins.
93 Additional pieces, not controlled by the player:
94 Piece Name Number Notes
95 + Obstacle 8 Immobile. Do not belong to either player. Can't be passed through.
96 # Enemy Piece 0 - 40 Indicates that the position on the board is occupied by an enemy piece.
97 . Empty NA Indicates that the position on the board is empty.
99 Players take turns to move their pieces. RED begins the game.
101 Pieces may only move one square horizontally or vertically unless otherwise stated.
102 Pieces may not move through squares occupied by allied pieces, or Obstacle (+) pieces.
103 Pieces may move into squares occupied by Enemy Pieces (#), in which case the piece with the lower rank (higher number) is destroyed.
105 Each player's pieces are hidden from the other player. When two pieces encounter each other, the ranks will be revealed.
107 The objective is to destroy all Enemy Pieces (#) or capture the Enemy Flag (also #).
111 In order to interface with stratego, an AI program must satisfy the following protocol.
112 Each query is followed by a newline, and responses are expected to be followed with a newline.
113 The queries are recieved through stdin, and responses should be written to stdout.
116 QUERY: YOUR_COLOUR OPPONENT_ID BOARD_WIDTH BOARD_HEIGHT
118 RESPONSE: 4 lines, each of length BOARD_WIDTH, of characters. Each character represents a piece. The characters are shown above.
120 RED's pieces are placed at the top of the board, and BLUE's pieces are placed at the bottom.
122 An AI program does not have to place all 40 pieces, but must at least place the flag ('F').
125 QUERY: START | CONFIRMATION
128 On the first turn, "START" is printed to the Red player.
129 On subsequent turns, the CONFIRMATION of the opponent's last turn is printed (see below).
131 BOARD_STATE consists of a BOARD_HEIGHT lines of length BOARD_WIDTH characters, each of which represents a single piece
132 as described in the GAME_RULES section. Each line ends with the newline character.
135 RESPONSE: X Y DIRECTION [MULTIPLIER=1] | NO_MOVE
136 X and Y are the coords (starting from 0) of the piece to move
137 DIRECTION is either UP, DOWN, LEFT or RIGHT
138 MULTIPLIER is optional and only valid for units of type Scout. Scouts may move through any number of unblocked squares
141 The AI program should print "NO_MOVE" if it is unable to determine a move.
142 This will typically occur when the only pieces belonging to the AI program are Bombs and the Flag.
144 CONFIRMATION: X Y DIRECTION [MULTIPLIER=1] OUTCOME | NO_MOVE {OK | ILLEGAL} | QUIT [RESULT]
146 OUTCOME may be either OK, ILLEGAL, KILLS or DIES
147 OK - Move was successful
148 ILLEGAL - Move was not allowed. If stratego was not started with the -i switch, the game will end.
149 KILLS ATTACKER_RANK DEFENDER_RANK - The piece moved into an occupied square and killed the defender.
150 DIES ATTACKER_RANK DEFENDER_RANK - The piece moved into an occupied square and was killed by the defender.
152 Most turns will be confirmed with: "X Y DIRECTION [MULTIPLIER=1] OUTCOME"
154 A confirmation of "NO_MOVE OK" occurs when the AI program made no move for a legitimate reason.
155 "NO_MOVE ILLEGAL" is printed if the AI program made no move for an illegitimate reason.
157 If both AI programs successively make a "NO_MOVE" response, then the game will end.
158 The player with the highest piece value will win, or a draw will be declared if the values are equal.
161 If the CONFIRMATION line is of the form:
163 Then the game is about to end.
165 If present, RESULT will be a direct copy of the message to stdout described in the EXIT/OUTPUT section below.
169 If a program fails to respond to a query within 2 (two) seconds, the game will end and that AI will be sent the ILLEGAL result.
170 Human players are not subject to the timeout restriction.
175 If the game ends due to a player either winning, or making an illegal move, stratego will print one of the following result messages to stdout.
177 NAME COLOUR OUTCOME TURN_NUMBER OUTCOME RED_PIECE_VALUE BLUE_PIECE_VALUE
180 NAME is the name of the player on whose turn the game ended,
181 COLOUR is the colour of that player,
182 OUTCOME is one of the following:
183 VICTORY - The indicated player won
184 DEFEAT - The indicated player lost
185 SURRENDER - The indicated player surrendered
186 DRAW - The game ended in a draw because neither player moved
187 DRAW_DEFAULT - The game ended in a draw because the maximum number of moves was exceeded
188 ILLEGAL - The indicated player loses due to an Illegal move/response
189 DEFAULT - The indicated player wins by default due to the other player making an Illegal move/response
190 BOTH_ILLEGAL - Both players made an Illegal move/response. Usually occurs due to simultaneous setup errors, or bad executable paths.
191 INTERNAL_ERROR - The game ended, even though it shouldn't have.
193 TURN_NUMBER is the number of turns that elapsed before the game ended
195 RED_PIECE_VALUE and BLUE_PIECE_VALUE are the summed piece values of the pieces of RED and BLUE respectively.
196 Bombs and Flags are worth zero, and the ranked pieces (Spys -> Marshal) are worth (11 - rank).
197 So the Spy is worth 1 point, ... the Marshal is worth 10.
199 (The initial piece values can be determined by running with -m 0)
202 stratego will then return exit code 0.
204 If an error occurs within stratego itself, an error message will be printed to stderr and return exit code 1.
205 If possible, stratego will print the message "QUIT" to both AI programs, and they should exit as soon as possible.
210 stratego has been observed to segfault occassionally after the end of a game. It is not yet known what is causing these errors.
211 They appear to occur most often when the result is a draw, however they have been observed to occur under all exit conditions except the Illegal case. The result is still printed to stdout. However this bug _must_ be fixed before stratego can be used by simulation scripts.
213 stratego is still a work in progress. Report another bug to the AUTHOR (see below).
219 0. This program is still a work in progress and subject to changes.
221 1. UCC Programming Competition 2012 Description
222 http://matches.ucc.asn.au/stratego/
224 2. UCC Programming Competition 2012 Git repository
225 git://git.ucc.asn.au/progcomp2012.git
229 irc://irc.ucc.asn.au #progcomp