## Understanding The Gamestate

Your calculateMove() function will be passed the current state of the game, the 'gameState'. The gameState is a python dictionary containing the following keys:

**Comparison**- A list that contains the results from your last guess. The first number represents the number of correct colours but incorrect position and the second number is where the colour and position are both correct. This entry will only exist once you have submitted at least one guess.**NumColours**- The number of different colours available for each peg in the hidden sequence.**NumPegs**- The number of pegs that make up each of the hidden sequences. This value will not change during the game and is determined by the game type you are currently playing.**DuplicatesAllowed**- Whether you are allowed duplicate coloured pegs in your hidden sequence. This value will not change during the game and is determined by the game type you are currently playing.**IsLeading**- A Boolean value indicating whether you are winning.**Round**- A number representing the current round of the game. If 0 then you are setting up your hidden sequence. If 1 you are trying to guess your opponents hidden sequence.**NumGuesses**- The total number of guesses you are allowed to try and find your opponents code. This value will not change during the game and is determined by the game type you are currently playing.**MyGuesses**- The number of guesses you have currently used.**OppGuesses**- The number of guesses your opponent has used.**myFinishedTime**- The epoch time you submitted the correct solution. Set to 'None' if you have not found the solution.**OppFinishedTime**- The epoch time your opponent submit the correct solution. Set to 'None' if they have not found the solution.**GameLength**- The game length in milliseconds.**MyScore**- If playing a series of games this is your running total number of games won.**OppScore**- If playing a series of games this is your opponents running total number of games won.**IsMover**- Always set to 'True' whilst the game is in play.**GuessesList**- A list of all your previous guesses.**GameStatus**- A string that will have value "RUNNING" if the game is in progress or a reason the game has ended otherwise.**GameId**- An integer representing the unique game id for the current game.**OpponentId**- A string containing the name of your opponent.

## How to Initially Set Your Hidden Peg Sequence

On game startup the 'Round' entry in gameState is set to 0. This move is setting **your** hidden peg sequence. The sequence is a list of numbers where each number represents a peg and the value of each number can be between 0 and the 'NumColours' minus 1. For example if 'NumPegs'=6 and 'NumColours'=8 a valid move would be:

move = {"Sequence": [0,1,2,3,6,7]}

## How to Submit a Guess

Once the 'Round' entry in gameState is set to 1 then you are trying to guess your opponents hidden sequence. A guess is a list of numbers where each number represents a peg in your opponents sequence. Again each peg can be any value between 0 and the 'NumColours' minus 1. For example if 'NumPegs'=4 and 'NumColours'=6 a valid guess would be:

move = {"Sequence": [2,0,1,5]}

If and when you submit the correct solution calculateMove() will no longer be called and your code will no longer be executed.

## Understanding the Comparison Result

Once you have submitted at least one guess the 'Comparison' entry in gameState will have a value. The first number represents the number of correct colours but incorrect position and the second number is where the colour and position are both correct. For example if you opponents secret code is [1,2,3,4] and you guess [1,3,4,5] your comparison result would be [2,1].

## Helper Functions

**randomSequence(pegs, colours, duplicates)**- Generates a random sequence of pegs given the number of pegs, colours and whether to allow duplicates.**compareGuess(guess, sequence)**- Compares two sequences and returns the difference in the same output format as 'Comparison' which is returned in the gameState.

## Jargon:

**Epoch time**- The number of seconds (or in our case milliseconds) that have elapsed since January 1 1970 00:00 UTC.