Go Quick Reference Guide

Understanding The GameState

The gameState is where all of the game information is held. It is a Python dictionary. Examples of accessing data in the gameState would be:

`gameState["IsMover"] gameState["Board"][0][2]`

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

  • Board - A 2-dimensional array of integers representing the state of the board. (See Understanding The Board)
  • PreviousBoard - A 2-dimensional array of integers representing the state of the board after your last move. If you are playing Capture Go then this value will always be an empty board. (See Understanding The Board)
  • IsMover - A Boolean value indicating whether it is your turn to move. It will always be ‘True` when in the calculateMove() function. (Delve deeper into the code if you want to do some processing during your opponent’s turn.)
  • ResponseDeadline - The epoch time, in milliseconds, that a successful move has to be sent and received by to prevent you from timing out.
  • Black - An integer representing the ID of the player who is using black stones. It will be either `0` or `1`.
  • MyRole - An integer representing your ID (`0` or `1`).
  • IsCaptureGo - A Boolean value indicating whether the game style you are playing is Capture Go.
  • CaptureTarget - An integer representing the target number of stones to capture throughout the game in order to win. If you are not playing Capture Go then this will always be `None`.
  • MyCaptures - An integer representing the number of stones you have captured so far in this game. If you are not playing Capture Go then this will always be `0`.
  • OpponentCaptures - An integer representing the number of stones captured by your opponent so far in this game. If you are not playing Capture Go then this will always be `0`.
  • MaxMoves - An integer representing the maximum number of moves allowed in the game from start to end. Once there have been this many moves the game will end. If you are playing Capture Go then this will always be `False`.
  • MoveNumber - The number of the move you are to make. If you are making the first move of the game then this will be `0`. Thus the value is equivalent to the number of moves that have already happened. If you are playing Capture Go then this will always be `0`.
  • LastMoveWasPass - A Boolean value indicating whether the opponent has just passed their turn. At the start of the game this is `False`.
  • ScoringMethod - A string with value `"STONE"`, `"TERRITORY"`, or `"AREA"` to indicate whether the scoring method for the game is stone scoring, territory scoring, or area scoring. If you are playing Capture Go then this will always be `None`.
  • GameStatus - A string that will have value "RUNNING" if the game is in progress, or a reason the game has ended otherwise.

Understanding The Board

The Board and the PreviousBoard 2-dimensional arrays in the gameState can contain the following integer values:

  • -1 An empty (that is, unoccupied) intersection.
  • 0 An intersection occupied by a stone belonging to the player with ID 0.
  • 1 An intersection occupied by a stone belonging to the player with ID 1.

Making A Valid Move

The value you have to return from the calculateMove() function is a dictionary which either specifies a location (X, Y) on the board to place a stone, or the location (-1, -1), indicating that you wish to pass your turn. The dictionary must have the following key value pairs:

  • "X" which takes values -1, 0, 1, 2, etc.
  • "Y" which takes values -1, 0, 1, 2, etc.

Here is an example of a valid move:
`{ "X": 0, "Y": 0 }`

Jargon

  • Epoch time - The number of seconds (or in our case milliseconds) that have elapsed since January 1 1970 00:00 UTC.
iconGoBlack.png
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License