GitLab now enforces expiry dates on tokens that originally had no set expiration date. Those tokens were given an expiration date of one year later. Please review your personal access tokens, project access tokens, and group access tokens to ensure you are aware of upcoming expirations. Administrators of GitLab can find more information on how to identify and mitigate interruption in our documentation.
stratego manages a game of Stratego. It stores the state of the board, and uses a simple protocol to interface with AI programs.
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
various AI strategies, written in any programming language. It will be used for the UCC Programming Competition 2012.
Unless the -h (--help) or -f switch is given, both red_player and blue_player must be supplied.
red_player
Should be either a path to an executable file which will control the Red player, or "human".
If set to "human", stratego will request the user to make moves for the Red player using stdin.
NOTES
1. There is no plan to support AI programs named "human". Deal with it.
2. The graphical interface for human players is... basic. Deal with it.
blue_player
As red_player, except for controlling the Blue player.
A WARNING ABOUT BUFFERING
The AI programs must unbuffer their stdin and stdout streams, otherwise it will be seen to be non-responsive.
If you C and you know a way to force the process started by exec() to have unbuffered stdin/stdout, please email the author.
In C or C++, unbuffering is accomplished with the following lines, which should appear near the start of main()
setbuf(stdin, NULL);
setbuf(stdout, NULL);
In python, unbuffering is accomplished by passing the -u switch to the interpreter, ie: The first line of a script reads:
#!/usr/bin/python -u
OPTIONS
-g
By default, graphics are disabled. If the -g switch is present, stratego will draw the game as it is played using SDL/OpenGL
-p
By default, even if graphics are disabled, the board state is not printed. If -p is present, the board will be printed to stdout.
If the system supports colour, the characters will be in colour.
Yes, If -p and -g are both present you will see both behaviours (overkill)!
-i
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.
That is, the move will not be made (effectively the player making the illegal move loses a turn).
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.
This is intended to prevent fits of rage due to the horrible graphical interface causing humans to make illegal moves.
-r
By default, the identities of all pieces are shown. If the -r switch is present, and graphics are enabled, red pieces will be disguised.
If graphics are disabled, the -r switch has no effect.
Pieces which have previously taken part in combat (and survived) will be revealed.
-b
As -r, except blue pieces will be disguised.
NOTE: Both -r and -b may be used together.
-o
By default, stratego does not log moves. If the -o switch is present, the result of each move is printed to a file.
If output_file is "stdout" then stdout will be used instead of a text file.
-t
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
between each move.
If stall_time is negative or "inf", stratego will wait for the user to press enter before moving to the next move.
It is tentatively planned to allow the user to enter various commands to alter the game or proceed to specified turns.
However this is slightly complicated. So it might never be done.
-m
By default, the game is declared a Draw after 5000 turns have ellapsed.
Use this option to change the maximum number of turns.
To play for an infinite number of turns, supply "inf" as max_number. This is not recommended for obvious reasons.
-f
By default, stratego requires red_player and blue_player to enact a game.
If this option is supplied, a file previously produced by using the -o switch is read, and the game reenacted.
All switches function as normal with -f.
NOTE: It is recommended that -g is used with -f.
-h, --help
If the -h switch is used, this page will be printed and stratego will exit.
GAME RULES
Each player controls up to 40 pieces on the Board. The pieces are represented by the following characters:
Piece Name Rank Number Abilities
1 Marshal 1 1 Dies if attacked by Spy
2 General 2 1
3 Colonel 3 2
4 Major 4 3
5 Captain 5 4
6 Lieutenant 6 4
7 Sergeant 7 4
8 Miner 8 5 Destroys Bombs
9 Scout 9 8 May move more through multiple empty squares
s Spy 10 1 If the Spy attacks the Marshal, the Marshal dies
B Bomb NA 6 Immobile. If any piece (except a Miner) attacks an enemy Bomb, that piece is destroyed.
F Flag NA 1 Immobile. If any piece attacks the enemy Flag, the controlling player wins.
Additional pieces, not controlled by the player:
Piece Name Number Notes
+ Obstacle 8 Immobile. Do not belong to either player. Can't be passed through.
# Enemy Piece 0 - 40 Indicates that the position on the board is occupied by an enemy piece.
. Empty NA Indicates that the position on the board is empty.
Players take turns to move their pieces. RED begins the game.
Pieces may only move one square horizontally or vertically unless otherwise stated.
Pieces may not move through squares occupied by allied pieces, or Obstacle (+) pieces.
Pieces may move into squares occupied by Enemy Pieces (#), in which case the piece with the lower rank (higher number) is destroyed.
Each player's pieces are hidden from the other player. When two pieces encounter each other, the ranks will be revealed.
The objective is to destroy all Enemy Pieces (#) or capture the Enemy Flag (also #).
Since 20/12 Bombs reflect the traditional rules; they are only destroyed by Miners.
In previous versions contact of an attacker other than a Miner with a Bomb destroyed the Bomb as well as the attacking piece.
PROTOCOL
In order to interface with stratego, an AI program must satisfy the following protocol.
Each query is followed by a newline, and responses are expected to be followed with a newline.
The queries are recieved through stdin, and responses should be written to stdout.
stratego manages a game of Stratego. It stores the state of the board, and uses a simple protocol to interface with AI programs.
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
various AI strategies, written in any programming language. It will be used for the UCC Programming Competition 2012.
Unless the -h (--help) or -f switch is given, both red_player and blue_player must be supplied.
red_player
Should be either a path to an executable file which will control the Red player, or "human".
If set to "human", stratego will request the user to make moves for the Red player using stdin.
NOTES
1. There is no plan to support AI programs named "human". Deal with it.
2. The graphical interface for human players is... basic. Deal with it.
blue_player
As red_player, except for controlling the Blue player.
A WARNING ABOUT BUFFERING
The AI programs must unbuffer their stdin and stdout streams, otherwise it will be seen to be non-responsive.
If you C and you know a way to force the process started by exec() to have unbuffered stdin/stdout, please email the author.
In C or C++, unbuffering is accomplished with the following lines, which should appear near the start of main()
setbuf(stdin, NULL);
setbuf(stdout, NULL);
In python, unbuffering is accomplished by passing the -u switch to the interpreter, ie: The first line of a script reads:
#!/usr/bin/python -u
OPTIONS
-g
By default, graphics are disabled. If the -g switch is present, stratego will draw the game as it is played using SDL/OpenGL
-p
By default, even if graphics are disabled, the board state is not printed. If -p is present, the board will be printed to stdout.
If the system supports colour, the characters will be in colour.
Yes, If -p and -g are both present you will see both behaviours (overkill)!
-i
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.
That is, the move will not be made (effectively the player making the illegal move loses a turn).
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.
This is intended to prevent fits of rage due to the horrible graphical interface causing humans to make illegal moves.
-r
By default, the identities of all pieces are shown. If the -r switch is present, and graphics are enabled, red pieces will be disguised.
If graphics are disabled, the -r switch has no effect.
Pieces which have previously taken part in combat (and survived) will be revealed.
-b
As -r, except blue pieces will be disguised.
NOTE: Both -r and -b may be used together.
-o
By default, stratego does not log moves. If the -o switch is present, the result of each move is printed to a file.
If output_file is "stdout" then stdout will be used instead of a text file.
-t
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
between each move.
If stall_time is negative or "inf", stratego will wait for the user to press enter before moving to the next move.
It is tentatively planned to allow the user to enter various commands to alter the game or proceed to specified turns.
However this is slightly complicated. So it might never be done.
-m
By default, the game is declared a Draw after 5000 turns have ellapsed.
Use this option to change the maximum number of turns.
To play for an infinite number of turns, supply "inf" as max_number. This is not recommended for obvious reasons.
-f
By default, stratego requires red_player and blue_player to enact a game.
If this option is supplied, a file previously produced by using the -o switch is read, and the game reenacted.
All switches function as normal with -f.
NOTE: It is recommended that -g is used with -f.
-h, --help
If the -h switch is used, this page will be printed and stratego will exit.
GAME RULES
Each player controls up to 40 pieces on the Board. The pieces are represented by the following characters:
Piece Name Rank Number Abilities
1 Marshal 1 1 Dies if attacked by Spy
2 General 2 1
3 Colonel 3 2
4 Major 4 3
5 Captain 5 4
6 Lieutenant 6 4
7 Sergeant 7 4
8 Miner 8 5 Destroys Bombs
9 Scout 9 8 May move more through multiple empty squares
s Spy 10 1 If the Spy attacks the Marshal, the Marshal dies
B Bomb NA 6 Immobile. If any piece (except a Miner) attacks an enemy Bomb, that piece is destroyed.
F Flag NA 1 Immobile. If any piece attacks the enemy Flag, the controlling player wins.
Additional pieces, not controlled by the player:
Piece Name Number Notes
+ Obstacle 8 Immobile. Do not belong to either player. Can't be passed through.
# Enemy Piece 0 - 40 Indicates that the position on the board is occupied by an enemy piece.
. Empty NA Indicates that the position on the board is empty.
Players take turns to move their pieces. RED begins the game.
Pieces may only move one square horizontally or vertically unless otherwise stated.
Pieces may not move through squares occupied by allied pieces, or Obstacle (+) pieces.
Pieces may move into squares occupied by Enemy Pieces (#), in which case the piece with the lower rank (higher number) is destroyed.
Each player's pieces are hidden from the other player. When two pieces encounter each other, the ranks will be revealed.
The objective is to destroy all Enemy Pieces (#) or capture the Enemy Flag (also #).
Since 20/12 Bombs reflect the traditional rules; they are only destroyed by Miners.
In previous versions contact of an attacker other than a Miner with a Bomb destroyed the Bomb as well as the attacking piece.
PROTOCOL
In order to interface with stratego, an AI program must satisfy the following protocol.
Each query is followed by a newline, and responses are expected to be followed with a newline.
The queries are recieved through stdin, and responses should be written to stdout.
<imgborder="0"src="screenshot.png"alt="Graphical output of 'stratego' manager program."title="Graphical output of 'stratego' manager program. Options '-g' for graphics and '-b' to hide Blue pieces that have not taken part in combat yet. Red and Blue are both linked to the 'asmodeus' AI. Taken with scrot on 7/12/11."width="327"height="344"/>
<imgborder="0"src="screenshot.png"alt="Graphical output of 'stratego' manager program."title="Graphical output of 'stratego' manager program. Options '-g' for graphics and '-b' to hide Blue pieces that have not taken part in combat yet. Red and Blue are both linked to the 'asmodeus' AI. Taken with scrot on 7/12/11."width="327"height="344"/>
<h3> Protocol </h3>
<h3> Protocol </h3>
<p> For the sake of simplicity and keeping things in one place, the protocol is now entirely described in the <ahref="http://matches.ucc.asn.au/progcomp2012/progcomp/judge/manager/manual.txt"/>manual page</a> of the manager program. All updates to the protocol will be reflected in that file. </p>
<p> For the sake of simplicity and keeping things in one place, the protocol is now entirely described in the <ahref="doc/manager_manual.txt"/>manual page</a> of the manager program. All updates to the protocol will be reflected in that file. </p>
<p><b> Warning:</b> The accuracy of the above file depends on how recently I pulled it from git. To ensure you get the latest version, find it under "manager/manual.txt" in the <ahref="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>git repository</a></p>
<p><b> Warning:</b> The accuracy of the above file depends on how recently I pulled it from git. To ensure you get the latest version, find it under "web/doc/manager_manual.txt" in the <ahref="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>git repository</a></p>
<p><b> Another Warning:</b> AI programs <b>must</b> unbuffer stdin and stdout themselves. This is explained in the manual page, but I figured no one would read it. It is fairly simple to unbuffer stdin/stdout in C/C++ and python, I have not investigated other languages yet. </p>
<p><b> Another Warning:</b> AI programs <b>must</b> unbuffer stdin and stdout themselves. This is explained in the manual page, but I figured no one would read it. It is fairly simple to unbuffer stdin/stdout in C/C++ and python, I have not investigated other languages yet. </p>