Module zttt¶
The module contains 2 main classes Both the classes inherit from the ZTBaseBoard class.
PvP: The class for the PvP game
PvC: The class for the PvC game
The module also contains the submodule zt_errors which contain the following errors
ZTError: The base class for all ZTErrors
ZTBadFunctionCall: The error raised when a function is called with the wrong arguments. Mostly used for debugging
ZTGameException: The error raised when a function call crashes the game
ZTWrongInput: The error raised when the input provided is not valid
- class zttt.PvP¶
Bases:
ZTBaseBoard- play(pos: int) None¶
Plays the player’s move at the position specified
- Parameters:
pos (int) – The position to play the player’s move
- Returns:
None
- Raise:
ZTGameException if the game is not in progress
- Raise:
ZTInvalidInput if the move is invalid
- class zttt.PvC(_engine_first: bool = True)¶
Bases:
ZTEngineFirst,ZTPlayerFirstClass for the PvC Game
- play(pos: int) None¶
Plays the player’s move at the position specified
- Parameters:
pos (int) – The position to play the player’s move
- Returns:
None
- Raise:
ZTGameException if the game is not in progress
- Raise:
ZTInvalidInput if the move is invalid
- class zttt._zt_core.ZTBaseBoard¶
Bases:
objectThis is the base class which is inherited by all the classes which are used in the module
- classmethod set_indicators(_player1: str = 'X', _player2: str = 'O', _space: str = ' ') None¶
Sets the indicators, a class method
- Parameters:
_player1 (str) – Indicator for player 1
_player2 (str) – Indicator for player 2
_space (str) – Indicator for empty position
- Returns:
None
- property board_list: List[int]¶
List containing the status of the board (Row Major Order)
- Returns:
A (duplicate) list of the board list
- Return type:
List[int]
- property status: bool¶
Whether the game is in progress or not
- Returns:
The status of the game
- Return type:
bool
- property move: int¶
The current move that is to be performed
- Returns:
Current Move Number
- Return type:
int
- property turn: int¶
The player whose turn it is to play
- Returns:
Player Number
- Return type:
int
- property winner: (None, <class 'int'>)¶
The winner of the game
- Returns:
Winner if the game is over, 0 is draw, None if no winner yet
- Return type:
(None, int)
- property history: List[int]¶
Returns the history of the game
- Returns:
A (duplicate) list of the history
- Return type:
List[int]
- property empty_positions: List[int]¶
Returns the list of empty positions
- Returns:
A (duplicate) list (in row major order from 0) of the empty positions
- Return type:
List[int]
- property empty_corners: List[int]¶
Returns the list of empty corners
- Returns:
List of the empty corners
- Return type:
List[int]
- property empty_edges: List[int]¶
Returns the list of empty edges
- Returns:
List of the empty edges
- Return type:
List[int]
- property highlighted: List[int]¶
Returns the highlighted positions of the board when there is a winner, empty list otherwise
- Returns:
A (duplicate) list of highlighted positions
- Return type:
List[int]
- property board: str¶
Returns the string representation of the board
- Returns:
board string
- Return type:
str
- property on_move: Callable[[int, int], None]¶
Returns the on_move event trigger
- Returns:
on_move event trigger
- Return type:
Callable[[int, int], None]
- property on_finish: Callable[[int], None]¶
Returns the on_move event trigger
- Returns:
_on_finish event trigger
- Return type:
Callable[[int], None]
Module zttt.zt_errors¶
The module contains the errors that can be raised by the zttt package.
- exception zttt.zt_errors.ZTError¶
Bases:
ExceptionBase class for all zt_errors.
- exception zttt.zt_errors.ZTBadFunctionCall¶
Bases:
AttributeError,ZTErrorRaised when a function is called with the wrong arguments. Mostly used for debugging.
- exception zttt.zt_errors.ZTGameException¶
Bases:
ZTErrorRaised when some invalid function call crashes the game.
- exception zttt.zt_errors.ZTInvalidInput¶
Bases:
ValueError,ZTGameExceptionRaised when the input provided is not valid.