haive.games.fox_and_geese.rich_ui ================================= .. py:module:: haive.games.fox_and_geese.rich_ui .. autoapi-nested-parse:: Enhanced Rich UI module for Fox and Geese game visualization. This module provides an enhanced rich console UI for visualizing the Fox and Geese game, with better styling, animated piece movements, and improved game information display. Classes ------- .. autoapisummary:: haive.games.fox_and_geese.rich_ui.FoxAndGeeseRichUI Module Contents --------------- .. py:class:: FoxAndGeeseRichUI(console = None) Enhanced Rich UI for Fox and Geese game visualization. This class provides a visually appealing terminal UI for Fox and Geese games, with styled components, animations, and comprehensive game information. Features: - Beautiful game board visualization with colored squares - Animated piece movements for fox and geese - Detailed game statistics and turn information - Move history tracking with visual indicators - Analysis visualization for both fox and geese strategies - Thinking animations and move highlights .. attribute:: console Rich console for output :type: Console .. attribute:: colors Color schemes for different UI elements :type: dict Initialize the UI. :param console: Optional Rich console instance .. py:method:: animate_move(state_before, state_after, delay = 0.5) Animate a move being made. Shows a smooth transition between the before and after states with visual indicators of what changed. :param state_before: Game state before the move :param state_after: State after the move :param delay: Delay in seconds for the animation :returns: None .. py:method:: create_analysis_panel(game_state) Create an enhanced panel showing the latest analysis. :param game_state: Current game state :returns: Rich panel with detailed analysis .. py:method:: create_board_table(game_state, highlight_positions = None, capture_position = None) Create an enhanced visual representation of the board. :param game_state: Current game state :param highlight_positions: Optional positions to highlight (for showing moves) :param capture_position: Optional position to highlight as a capture :returns: Rich table representing the board .. py:method:: create_game_info_panel(game_state) Create an enhanced panel with game information. :param game_state: Current game state :returns: Rich panel with detailed game info .. py:method:: create_layout(game_state, highlight_positions = None, capture_position = None, legal_moves = None) Create the enhanced complete rich UI layout. :param game_state: Current game state :param highlight_positions: Optional positions to highlight :param capture_position: Optional position being captured :param legal_moves: Optional list of legal moves :returns: Complete rich layout .. py:method:: create_legal_moves_panel(game_state, legal_moves = None) Create a panel showing legal moves for the current player. :param game_state: Current game state :param legal_moves: Optional list of legal moves :returns: Rich panel with legal moves info .. py:method:: create_move_history_panel(game_state) Create an enhanced panel showing move history. :param game_state: Current game state :returns: Rich panel with detailed move history .. py:method:: display_final_results(final_state) Display enhanced final game results. :param final_state: Final game state .. py:method:: display_game_with_animation(state_sequence, delay = 1.0) Display a sequence of game states with smooth transitions. This is useful for replaying a game or showing a sequence of moves with visual transitions between states. :param state_sequence: List of game states in sequence :param delay: Delay in seconds between states :returns: None .. py:method:: display_state(state_data, highlight_positions = None, capture_position = None, legal_moves = None) Display the game state using enhanced rich UI. :param state_data: State data in various formats :param highlight_positions: Optional positions to highlight :param capture_position: Optional position being captured :param legal_moves: Optional list of legal moves :returns: True if display was successful, False otherwise .. py:method:: display_welcome() Display welcome message. .. py:method:: extract_game_state(state_data) Extract FoxAndGeeseState from various input formats. :param state_data: State data in various formats :returns: FoxAndGeeseState instance or None if extraction fails .. py:method:: run_fox_and_geese_game(agent, delay = 1.0) Run a complete Fox and Geese game with UI visualization. This method handles the entire game flow, including initialization, move animation, and final results display. :param agent: The game agent that manages the game logic :param delay: Delay in seconds between game states :returns: Final game state .. py:method:: show_move(move, state_before, state_after) Display an animated move being made. Shows the move with highlighting of the relevant positions. :param move: The move being made :param state_before: State before the move :param state_after: State after the move :returns: None .. py:method:: show_thinking(player, message = 'Thinking...') Display a thinking animation for the current player. Shows a spinner animation with player-colored text to indicate that the player is thinking about their move. :param player: Current player ("fox" or "geese") :type player: str :param message: Custom message to display. Defaults to "Thinking...". :type message: str, optional :returns: None