There are two programs in this repository:
-
GameMaster - A Java program that controls the interactions between agents and a master running the game.
-
breakthrough - A C++ program that implements a server to play the game breakthrough.
GameMaster is a Java programs that controls the interactions between agents and a master running the game.
The following commands are server commands:
- #getname ID
- Returns the name of player with ID.
- #master
- Tells the server that the programs should receive all messages and sends broadcasts.
- #name NAME
- Declares the current agent to be named NAME. No spaces are allowed. The names server and observer are reserved.
- #players
- Returns the number of connected players.
- #quit
- Immediately terminates the game. This message is always broadcast to all clients.
Any other command sent with a # prefix will be ignored and not sent on to the other clients.
breakthrough is a C++ program that plays the game breakthrough
During the game, the following commands will be issued:
- BEGIN BREAKTHROUGH player1 player2
- Starts a game using with player1 starting first. The names player1 and player2 will be replaced with the names provided to the server with the #name command.
- FINAL winner BEATS loser
- Declares the game over with the winner and loser specified. As with BEGIN, the names declared by the #name command will be used in place of winner and loser.
- MOVE from_location TO to_location
- Moves the piece at from_location to to_location. Locations are specified with a letter and number, separated by a space. The letter designates the column and the number the row. The locations are the same as algebraic chess notation except since all pieces are the same, no notation of the pieces are made. An example move is "MOVE a 2 TO a 3".
During the game, there is only one valid command to send:
At the start of the game, player1 has their pieces in rows 1 and 2, whereas player2 has their pieces in rows 7 and 8.
To make your program interact, it will communicate over stdin and stdout (System.in and System.out in Java). You may freely write to stderr (System.err) if you wish to see diagnostic information during game play.
See the source breakthrough/src/RandomPlayer.cpp to see a simple implementation of an agent that selects moves randomly. There are also three sample agent implementations in the SampleAgents directory in C, C++, and Java.
Since GameMaster is Java, a simple "javac GameMaster.java" in the appropriate directory is enough.
To build breakthrough, the build is operating system dependent.
If you are using Visual Studio 2012 on Windows, load the solution file VS2012\breakthrough.sln and build the two projects contained within.
If you are using Linux, use CMake. Create a new build directory, then in a terminal execute 'cmake path/to/breakthrough; make'. Alternatively the provided makefile should also work.
If you are using OSX, the provided makefile should work. Alternatively the CMake build should also work, if you have CMake installed.
If there are any problems compiling, please contact Will.
To start a game between two random players type the following:
java GameMaster -1 'path/to/breakthrough_random player1' -2 'path/to/breakthrough_random player2' -m 'path/to/breakthrough'
Alternatively, the game setup can be stored in a response file like
--player1=path/to/breakthrough_random player1
--player2=path/to/breakthrough_random player2
--master=path/to/breakthrough
It can then be loaded like:
java GameMaster @response_file_name
A sample response file is included named Random.vs.Random.txt.
Running GameMaster with no arguments, or the argument --help, will display the full set of options that the program supports.
An example of what a game looks like between two random players may look like:
$ java -cp GameMaster/ GameMaster @Random.vs.Random.txt
Will start game run by: 'breakthrough/breakthrough_master'
Player1: 'breakthrough/breakthrough_random Random1'
Player2: 'breakthrough/breakthrough_random Random2'
0:stdout all: #name server
0:stdout all: #master
0:stdout all: #players
Received #players query from server; answer: 1
1:stdout: #name Random1
2:stdout: #name Random2
0:stdout all: #players
Received #players query from server; answer: 3
0:stdout all: #getname 0
Received #getname query from server; answer: server
0:stdout all: #getname 1
Received #getname query from server; answer: Random1
0:stdout all: #getname 2
Received #getname query from server; answer: Random2
0:stdout all: BEGIN BREAKTHROUGH Random1 Random2
1:stdout: MOVE f 2 TO e 3
0:stderr: Turn by 1:Random1 took 0h 0m 0s 11ms
0:stdout all: MOVE f 2 TO e 3
2:stdout: MOVE f 7 TO e 6
0:stderr: Turn by 2:Random2 took 0h 0m 0s 16ms
0:stdout all: MOVE f 7 TO e 6
1:stdout: MOVE c 2 TO c 3
0:stderr: Turn by 1:Random1 took 0h 0m 0s 16ms
0:stdout all: MOVE c 2 TO c 3
2:stdout: MOVE d 7 TO d 6
...
1:stdout: MOVE c 7 TO c 8
0:stdout all: MOVE c 7 TO c 8
0:stderr: Turn by 1:Random1 took 0h 0m 0s 16ms
0:stdout all: FINAL Random1 BEATS Random2
0:stdout all: #quit
2:stderr: I, Random2, have lost
$