Dominoes Quick Reference Guide

Your Main Function: calculateMove(gameState)

The calculateMove(gameState) function is the equivalent of your main function. This is where you need to make your changes and where you will control the game.
The calculateMove(gameState) function receives information about the game in a Python dictionary called gameState() and returns a game move.

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:
#This will return the current state of the board
gameState["IsMover"]
gameState["MyDominoes"][2][4]
Your calculateMove(gameState) function will be passed the current state of the game, in the form of the gameState.
The gameState contains the following keys:

  • MyDominoes - A 2-dimensional array of integers representing the the dominoes in your hand. (See Understanding The dominoes)
  • IsMover - A Boolean value indicating whether it is your turn to move. It will always be true when in the calculate_move() function.
  • ResponseDeadline - The epoch time, in milliseconds, that a successful move has to be sent and received by to prevent you from timing out.
  • first_center_dominoes - the first domino added to the domino board at the centre (See Understanding The dominoes)
  • center_dominoes - All the dominoes in the domino board. (See Understanding The dominoes)
  • 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 Dominoes

Each domino for now only has 6 dots at maximum on the top or at the bottom of the domino
An example of the centre_domino:
[ [4,0], [0,3], [3,6], [6,4], [4,4], [4,3] ]
Would visually be displayed as follows:
center_dominoes.png
The domino in red block is the first_centre_domino
An example of the MyDomino:
[ [1,6], [2,2], [6,0] ]
Would visually be displayed as follows:
MyDominoes.png

Making a Valid Move

The value you have to return from the calculateMove() function is a dictionary states the domino you want to move and the position you want it to move to
The suitable_domino should be in your hand and the "Position" should be either "R" or "L"
Here is an example of valid moves:
move = { " suitable_domino": [2, 1],
" Position": “R”}
But the suitable domino must have a number that matches a number on one open end of the domino board and the position should be correctly matched.

Jargon

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