haive.games.mastermind.state_manager ==================================== .. py:module:: haive.games.mastermind.state_manager .. autoapi-nested-parse:: State manager for the Mastermind game. This module defines the state manager for the Mastermind game, which manages the state of the game and provides methods for initializing, updating, and analyzing the game state. Classes ------- .. autoapisummary:: haive.games.mastermind.state_manager.MastermindStateManager Module Contents --------------- .. py:class:: MastermindStateManager Bases: :py:obj:`haive.games.framework.base.state_manager.GameStateManager`\ [\ :py:obj:`haive.games.mastermind.state.MastermindState`\ ] Manager for Mastermind game state. This class provides methods for initializing, updating, and analyzing the game state. .. py:method:: add_analysis(state, player, analysis) :classmethod: Add an analysis to the state. :param state: The current game state. :param player: The player who performed the analysis. :param analysis: The analysis to add. :returns: Updated state with the analysis added. :rtype: MastermindState .. py:method:: apply_move(state, move) :classmethod: Apply a guess to the current state and return the new state. :param state: The current game state. :param move: The guess to apply. :returns: A new game state after applying the guess. :rtype: MastermindState :raises ValueError: If the move is invalid. .. py:method:: check_game_status(state) :classmethod: Check and update the game status. For Mastermind, this is handled in apply_move, so this method just returns the state. :param state: The current game state. :returns: The game state (unchanged). :rtype: MastermindState .. py:method:: get_legal_moves(state) :classmethod: Get all legal moves for the current state. For Mastermind, this is impractical to enumerate all possible color combinations, so this method returns an empty list. The agent will generate guesses based on analysis. :param state: The current game state. :returns: An empty list (agent should generate its own guesses). :rtype: List[MastermindGuess] .. py:method:: get_possible_codes(state) :classmethod: Get all possible secret codes that are consistent with all guesses and. feedback so far. This is computationally expensive for a full game, so it's limited to use for analysis. :param state: The current game state. :returns: Set of possible codes as tuples. :rtype: Set[Tuple[str, ...]] .. py:method:: get_winner(state) :classmethod: Get the winner of the game, if any. :param state: The current game state. :returns: The winner, or None if the game is ongoing. :rtype: Optional[str] .. py:method:: initialize(**kwargs) :classmethod: Initialize a new Mastermind game. :param \*\*kwargs: Keyword arguments for game initialization. codemaker: Player who creates the code (player1 or player2). Default is player1. colors: List of valid colors. Default is standard 6 colors. code_length: Length of the secret code. Default is 4. max_turns: Maximum number of turns. Default is 10. secret_code: Optional predetermined secret code (List[str] or ColorCode). :returns: A new Mastermind game state. :rtype: MastermindState