Skip to content
Thibault Serti edited this page Jul 5, 2019 · 3 revisions

The engine part consists in engine.py and exceptions.py. Its role is to make the rule be followed. There is two classes :

  • Board represents the physical Board : state of the board (number of seeds in each pit), and some functions used to get values on the board (get_pit, empty_side)
  • Game is created for each game we want to play.

Game

The game init function defines the algos available, setup a initial board and defines the total number of seeds eaten. After the game init we should set the player's types.

run_game

The run_game function starts the game and handles with the end of the game. When it comes to make a play effective, if calls the play function that (in the case it's not the END of the game) will call itself the move function that will deal with rule of an effective move (eating and moving seeds).

move

The move function takes one optional parameters : the board on which the move shall take effect. By default this parameter is equal to the board defines in the Game init function.

allowed

The allowed function takes one pit and returns if the move is allowed or not. It raises several types of Exceptions in case of illegal move. This function is called by the AI to know if they can play the pit they've decided to play. If they cannot, the move is not played and the AI has to try another play.

Clone this wiki locally