games.mancala.state_original¶

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¶

MancalaState

State for a Mancala game.

Module Contents¶

class games.mancala.state_original.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.

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.

Parameters:

data (Any)

copy()¶

Create a deep copy of the current state.

Returns:

A new instance with the same values

Return type:

MancalaState

get_valid_moves(player=None)¶

Get valid moves for the current or specified player.

Parameters:

player (str | None) – Player to get moves for (“player1” or “player2”). If None, uses current turn.

Returns:

List of valid pit indices that can be played

Return type:

List[int]

get_winner()¶

Determine the winner of the game.

Returns:

“player1”, “player2”, “draw”, or None if game ongoing

Return type:

Optional[str]

classmethod handle_analysis_data(data)¶

Handle conversion of analysis data to proper types.

classmethod handle_initialization_data(data)¶

Handle special initialization patterns from the framework.

classmethod initialize(stones_per_pit=4, **kwargs)¶

Initialize a new Mancala game state.

Parameters:
  • stones_per_pit (int) – Number of stones to place in each pit initially

  • **kwargs – Additional keyword arguments for customization

Returns:

A new initialized game state

Return type:

MancalaState

is_game_over()¶

Check if the game is over.

Returns:

True if game is over, False otherwise

Return type:

bool

model_dump(**kwargs)¶

Override model_dump to ensure proper serialization.

Return type:

dict[str, Any]

classmethod validate_board(v)¶

Validate the board has exactly 14 positions.

property board_string: str¶

Get a string representation of the board.

Return type:

str

property player1_score: int¶

Get player 1’s score (store).

Return type:

int

property player2_score: int¶

Get player 2’s score (store).

Return type:

int