games.mancala.state¶
State for the Mancala game.
This module defines the state for the Mancala game, which includes the board, turn, game status, move history, free turn, winner, and player analyses.
Classes¶
State for a Mancala game. |
Functions¶
|
Extract analysis data from an AIMessage object. |
Module Contents¶
- class games.mancala.state.MancalaState(/, **data)¶
Bases:
haive.games.framework.base.state.GameState
State for a Mancala game.
This class defines the structure of the Mancala game state, which includes the board, turn, game status, move history, free turn, winner, and player analyses.
- Parameters:
data (Any)
- board¶
List of 14 integers representing the game board.
- turn¶
The current player’s turn.
- game_status¶
The status of the game.
- move_history¶
List of moves made in the game.
- free_turn¶
Whether the current player gets a free turn.
- winner¶
The winner of the game, if any.
- player1_analysis¶
Analysis data for player 1.
- player2_analysis¶
Analysis data for player 2.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- determine_winner()¶
Determine the winner of the game.
- Returns:
The winner of the game or ‘draw’ if tied.
- Return type:
Literal[‘player1’, ‘player2’, ‘draw’]
- display_board()¶
Display the board in a human-readable format.
- Returns:
A string representation of the current board state.
- Return type:
- get_scores()¶
Get the current scores for both players.
- get_valid_moves(player)¶
Get valid moves for the specified player.
- classmethod handle_analysis_data(data)¶
Handle conversion of analysis data to proper types.
- Parameters:
data (Any)
- Return type:
Any
- classmethod handle_initialization_data(data)¶
Handle special initialization patterns from the framework.
- Parameters:
data (Any)
- Return type:
Any
- classmethod initialize(**kwargs)¶
Initialize the Mancala game state.
- Parameters:
**kwargs – Optional parameters including stones_per_pit.
- Returns:
A fully initialized Mancala game state.
- Return type:
- is_game_over()¶
Check if the game is over.
- Returns:
True if the game is over, False otherwise.
- Return type: