core.BoardAndRules module¶
-
class
BoardAndRules(game)[source]¶ Represents the rules of the game, saves the present state of the game and checks that the players follow the rules.
Variables: - game (Game) – A reference to the game.
- boardS (BoardState) – Represents the present physical board.
-
extractLines()[source]¶ Extracts the 8 lines than can be completed:
- 3 vertical: left -> right,
- 3 horizontal: up -> down,
- 2 diagonal: 11->33 & 31->13.
Returns: The list of lines Return type: list of list
-
getBoard()[source]¶ Returns: a copy of the self.board that will not be updated when a new movement is made Return type: BoardState
-
play(mvt)[source]¶ Verifies that the movement of the player follows the rules and writes it on the board.
Also sets
Movement.turnand registers the movement in the listGame.movementsRegisters boardS inGame.statesParameters: mvt (Movement) – The Movement the player wants to play Returns: True if the movement is possible, else False Return type: bool