Assignment 5 – Generating and Scoring Moves
Due Wednesday 4/27 5:00pm for the testing deliverables and Friday 4/29 11:59pm for the code deliverables
This assignment you will build two functions that are useful for making an automated player.
Please note: you may not make a copy of your previous assignment and start modifying it for this one. You must keep a single code base and simply call into it different ways for the different assignments.
1 Move Generation
The first function you will make is one that, given a game state and a player state, generates a new player state that corresponds to taking a move. You must define a function with that specific signature and then call it from the driver code; it should not be mixed into your driver code.
Feel free to use any strategy you wish to generate a move but a good, basic strategy is to simply ignore the effects and either place a house or mark a refusal, as the effects are always optional. That is, search in each row for a spot where one of the numbers on the construction cards fit. If you find one, make a game state with that newly built house. If you don’t, increment the refusal count.
Testing Deliverables: In your team’s GitHub repository, create a directory “Deliverables/5/5.1/” and put at least ten input files that each have a single JSON list containing two objects: the game state, followed by a player state. The output file should also include a player state that corresponds to making a move the game and player state in the input file. The input player state must not have three refusals (0, 1, or 2 are all okay) nor may it have all of the homes filled in, nor may it have all three of the city plans claimed (or the game would be over).
You will receive up to twenty points for your tests, two points for each valid input file that does not duplicate any tests.
Code Deliverables: In your team’s GitHub repository, create a directory “Deliverables/5/5.1/” and deposit there a Makefile for your test driver. It should accept one JSON objects on stdin, a list that contains two objects: the game state followed by the player state. It should convert them to the internal representation of the player and game states and then decide on a legal next move and print the corresponding JSON to stdout. The input player state will not correspond to a game that is over.
Note that your code not have to produce the particular state that is shown in your test case. The test case just has to show one of the possible legal next moves.
You will receive up to 50 points for your code.
2 Scoring a Move
The second function you will make for this week accepts a player state and a list of numbers representing the other player’s temp agency counts, and it will return the score as if the game was over. See the rule book for the precise scoring function and the empty sheet image is helpful too.
As an example this player state:
with this is the corresponding JSON:
{"agents":[0,0,0,2,0,4],"city-plan-score":["blank",6,"blank"],"refusals":0,"streets":[{"homes":[2,false,[false,10,false],[true,"blank",false],[false,11,false],[false,"blank",false],[true,13,false],[false,[13,"bis"],false],[false,15,false],[false,16,false],[true,"blank",false]],"parks":1,"pools":[false,false,true]},{"homes":[5,false,[false,"blank",false],[false,"blank",false],[false,"blank",false],[false,6,false],[false,10,false],[false,"blank",false],[true,11,false],[false,[11,"bis"],false],[false,[12,"bis"],false],[false,12,false]],"parks":3,"pools":[true,false,false]},{"homes":["blank",false,[false,1,false],[false,2,false],[false,3,false],[true,11,false],[false,12,false],[false,"blank",false],[false,"blank",false],[false,13,false],[false,14,false],[false,15,false],[false,16,false]],"parks":5,"pools":[false,false,false]}],"temps":3}
scores 53 points, assuming no other players have used the temp agency.
Testing Deliverables: In your team’s GitHub repository, create a directory “Deliverables/5/5.2/” and put at least ten input files that each have one JSON list with two objects: a player state, followed by a list of numbers representing other player’s counts of uses of the temp agency. The output file should be the correct score.
You will receive up to twenty points for your tests, two points for each valid input file that does not duplicate any tests.
Code Deliverables: In your team’s GitHub repository, create a directory “Deliverables/5/5.2/” and deposit there a Makefile for your test driver. It should accept two JSON objects on stdin and it should convert the first one to the internal representation of the player state. The second one will be a list of numbers representing the other player’s temp agency counts. Your code should determine the score, as if the game were over. It should print that score to stdout (using the JSON number format, without decimals).