Really Quick Start

SG
Last updated 2 months ago

If you want the bare minimum instructions, or, if you're attending one of our events or an on online video and you just want the quick notes about what is important to start playing games, then...

Getting Started

  • From the Editor screen select the Game Type that you want to play

  • Every game comes with working template code that will have been loaded into the Editor for you

  • You can hit the Run button at the top right of the Editor and the game will play using the template code in the Editor window.

Editing the code

  • The calculate_move() function in the template code is the equivalent of your main() function

  • When you click the Run button in the Editor, the calculate_move() function is repeatedly called by our Game Manager every time you need to make a move

  • calculate_move()

    • receives a JSON object describing the current state of the game

    • returns a JSON object that represents the move you want to make in the game

  • Click on the Book icon in the very right hand column of the Editor page for an explanation of the gameState and Move objects, or, go to the Programmer's Reference help page here. For each game we explain

    • All the fields in the JSON gamestate object and what each field is for

    • The JSON you need to create to return a Move in each game.

Implementing the strategy

  • Between receiving the gameState at the start of calculateMove and returning the move you want to make in the game at the end of calculateMove is where you need to implement your strategy.

Special Notes

  • calculate_move() will be called each time you can make another move in the game. You only ever calculate one move at a time and return this singular move to the Game Manager by returning it from the calculate_move() function.

  • Any regular variables in your code do not persist between calls to calculate_move(). This is why you receive the full and current state of the game in the gameSate JSON that is passed to calculate_move().

  • Global variables, declared outside of the calculate_move() functions will persist between calls to calculate_move()

    • You need to check if the global variable exists before initialising it otherwise you would initialise it every time calculate_move is called. For example:

if not 'myVar' in globals():
myVar = "initial value"