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:
- Connections - An integer that shows how many counters you need to connect to win.
- IsMover - A Boolean value indicating whether it is your turn to move. It will always be true when in the calculateMove() function.
- ResponseDeadline - The epoch time, in milliseconds, that a successful move has to be sent and received by to prevent you from timing out..
- Board - A 2-dimensional array of integers representing the state of the board also see 'Understanding The Board' below.
- 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.
Understanding The Board
An example of a board:
[[-1, 0, 1, 1, -1, -1, -1], [-1, 0, 0, 1, -1, -1, -1], [-1, 0, 0, 0, 1, -1, -1], [-1, 1, 1, 0, 1, -1, -1], [-1, 0, 1, 1, 1, -1, -1], [0, 1, 1, 0, 0, 0, 0]]
Would visually be displayed as follows:

The boards integers in the Gamestate can contain the following values:
- -1 - A hole that hasn't been used and that contains nothing.
- 1 - A hole containing one of your counters.
- 0 - A hole containing one of your opponents counters.
How to Submit a Move
To submit a move you need to return in calculateMove, an integer of the column you want to place your counter in. This starts with column 0 and the highest column is (len(board[0]) - 1). You cannot submit a move for a column that is already full. For example:
return {"Column": 4}
Would place a counter in the 5th column from the left.
The game goes on until the board is full or a player connects the required number of counters (gamestate['Connections'] which is dependent on the gameStyle).
Jargon:
- Epoch time - The number of seconds (or in our case milliseconds) that have elapsed since January 1 1970 00:00 UTC.