Assignment 6 – Backgammon: a remote player
Due Wednesday 5/5 5:00pm for the testing deliverables and Friday 5/7 11:59pm for the code deliverables
1 Design, Build and Test
Implement a remote player adapter that, given either of your backgammon players from assignment 5 (or a new player that you might implement later), plays that player’s strategy over the network.
Your adapter should read JSON inputs from a TCP/IP port whose details (IP and port number) are provided on stdin. That is, your program will not receive boards and other such information on stdin as you have been doing until now. Instead, it should expect a JSON value on stdin that will inform it how to connect over the network to the game. This is the format of the initial message, where number is a JSON number and string is a JSON string.
network-config | ::= | { "host" : string, "port" : number } |
This restriction is to accommodate python’s JSON library, which seems to require either using the library in a complex way or knowing where the end of the object is before parsing begins.
Once your player receives network-config on stdin, it should connect to the already-running server at the given network address. Ater the player has connected to the given host and port it should expect messages matching input to appear and it should respond with the appropriate element of the output message. These messages correspond to the operations that your player implemented in assignment 5.
input | ::= | "name" |
| | { "start-game" : [ color, string ] } | |
| | { "take-turn" : [ board, dice ] } | |
| | { "end-game" : [ board, boolean ] } | |
output | ::= | { "name" : string } |
| | "okay" | |
| | { "turn" : [ [ cpos, cpos ], ... ] } | |
boolean | ::= | true |
| | false |
That is, when the player sees the message "name" it must respond with one that has the member "name". When it sees a message with the member "start-game", it must respond with the JSON string "okay". When it sees a message with the member "take-turn", it must respond with the JSON that has the member "turn". And finally when is sees a message with the member "end-game", it must also respond with the string "okay".
Testing Deliverables: In your team’s GitHub repository, create a directory named "Deliverables/6/6.1/" and deposit five test cases there. The format for these test cases is identical to the format for assignment 5, but the test cases must be different to count.
You will receive up to ten points for your tests, two points for each valid pair of input and output files.
Code Deliverables: In the same "Deliverables/6/6.1" directory in your team’s GitHub, place a Makefile for your remote player adapter. As usual make should produce run. The run executable will then be supplied the networking information.
You will receive up to fifty points for your remote player adapter depending on how many tests its test driver passes.