core.BoardState module¶
-
class
BoardState(hash=None)[source]¶ Represents the physical board.
Variables: state (3-list (line) of 3-list (column)) – The state of the board: initialised with “0”: [[0, 0, 0], [0, 0, 0], [0, 0, 0]]usesplayer.orderto put “1” or “2” where the players play.Parameters: hash (int, optional) – If hashis in **kwargs, it will be used to fill the board, default is None.Examples
emptyB = BoardState() fullB = BoardState(hash=122121121)
-
__hash__()[source]¶ Returns: An integer created by the concatenation of all the cases Return type: int Examples
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]returns12345678Warning
First 0 is gone!
-
__len__()[source]¶ Returns: the turn of the board: counts the 0 and deduces the turn T = 9 - nb(0)Return type: int
-
__repr__()[source]¶ Returns: 3 lines representing the board (plus one line above and one under) with X and O instead of 1 and 2 Return type: string
-
copy()[source]¶ Returns: A new identical copy of BoardState (useful for storage) Return type: BoardState
-