Protocol

Game loop

The run() function uses its arguments, the receive_input and send_output callables, to get player moves and send game-related info, respectively.

The former takes a Side as its argument, stating which side is expecting input from. It should return a 2-tuple of:

  • an InputType, indicating the input’s purpose

  • a 2-tuple of (or None under circumstances):

    • an int

    • an int (or None under circumstances)

The latter takes an OutputType as its first argument, indicating the output’s purpose. Its second argument is the data, which can be a GameState, a tuple of 2 ints, an InvalidMoveCode, or a Side. It can optionally take a third argument, a Side, indicating which side the output is addressed to. If the third argument is ommited (should have a None default value), the output concerns both sides.

Moving

The board’s points are indexed from bottom right to bottom left, then top left to top right. The first player’s base is the bottom right quarter.

The move data should be a 2-tuple, consisting of:

  • the index of the die that is intended to be played, considering the order of the die rolls as they were sent by the game

  • the index on the board, of the piece to be moved (from source to desitnation), or None if player has pieces that have been hit

In case the move is invalid, send_output is called with OutputType.INVALID_MOVE, an InvalidMoveCode, and the current Side. Below is described which codes are sent in which cases: