haive.games.mancala.state ========================= .. py:module:: haive.games.mancala.state .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: haive.games.mancala.state.MancalaState Functions --------- .. autoapisummary:: haive.games.mancala.state.extract_analysis_from_message Module Contents --------------- .. py:class:: MancalaState(/, **data) Bases: :py:obj:`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. .. attribute:: board List of 14 integers representing the game board. .. attribute:: turn The current player's turn. .. attribute:: game_status The status of the game. .. attribute:: move_history List of moves made in the game. .. attribute:: free_turn Whether the current player gets a free turn. .. attribute:: winner The winner of the game, if any. .. attribute:: player1_analysis Analysis data for player 1. .. attribute:: 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. .. py:method:: determine_winner() Determine the winner of the game. :returns: The winner of the game or 'draw' if tied. .. py:method:: display_board() Display the board in a human-readable format. :returns: A string representation of the current board state. .. py:method:: get_scores() Get the current scores for both players. :returns: Dictionary with player1 and player2 scores. .. py:method:: get_valid_moves(player) Get valid moves for the specified player. :param player: The player to get valid moves for. :returns: List of valid pit indices the player can choose from. .. py:method:: handle_analysis_data(data) :classmethod: Handle conversion of analysis data to proper types. .. py:method:: handle_initialization_data(data) :classmethod: Handle special initialization patterns from the framework. .. py:method:: initialize(**kwargs) :classmethod: Initialize the Mancala game state. :param \*\*kwargs: Optional parameters including stones_per_pit. :returns: A fully initialized Mancala game state. :rtype: MancalaState .. py:method:: is_game_over() Check if the game is over. :returns: True if the game is over, False otherwise. .. py:method:: validate_board(v) :classmethod: Validate that the board has exactly 14 positions. :param v: The board to validate. :returns: The validated board. :raises ValueError: If board doesn't have exactly 14 positions. .. py:function:: extract_analysis_from_message(analysis) Extract analysis data from an AIMessage object. :param analysis: The analysis object to extract from. :returns: Extracted analysis data or None if extraction fails.