haive.games.dominoes.rich_ui ============================ .. py:module:: haive.games.dominoes.rich_ui .. autoapi-nested-parse:: Enhanced Rich UI module for Dominoes game visualization. This module provides an enhanced rich console UI for visualizing the Dominoes game, with better styling, clearer representation of dominoes, and improved game animations. Classes ------- .. autoapisummary:: haive.games.dominoes.rich_ui.DominoesRichUI Module Contents --------------- .. py:class:: DominoesRichUI(console = None) Enhanced Rich UI for Dominoes game visualization. This class provides a visually appealing terminal UI for Dominoes games, with styled components, animations, and comprehensive game information. Features: - Beautiful domino tile visualization with ASCII art - Game board with clear indication of playable ends - Player hands with pip count and tile organization - Game information and score tracking - Move history and player analysis - Thinking animations and move visualizations .. attribute:: console Rich console for output :type: Console .. attribute:: layout Layout manager for UI components :type: Layout .. attribute:: colors Color schemes for different UI elements :type: dict .. rubric:: Examples >>> ui = DominoesRichUI() >>> state = DominoesState.initialize() >>> ui.display_state(state) # Display the initial game state 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: Game state after the move :param delay: Delay in seconds for the animation :returns: None .. py:method:: create_analysis_panel(game_state) Create a panel showing the latest analysis. :param game_state: Current game state :returns: Rich panel with analysis info .. py:method:: create_board_panel(game_state) Create a visual representation of the dominoes board. :param game_state: Current game state :returns: Rich panel representing the board .. py:method:: create_domino_tile_art(tile, open_end = False) Create ASCII art representation of a domino tile. :param tile: The domino tile to represent :param open_end: Whether this tile is at an open end of the board :returns: Rich Text object with tile representation .. py:method:: create_game_info_panel(game_state) Create a panel with game information. :param game_state: Current game state :returns: Rich panel with game info .. py:method:: create_layout(game_state) Create the complete rich UI layout. :param game_state: Current game state :returns: Complete rich layout .. py:method:: create_move_history_panel(game_state) Create a panel showing move history. :param game_state: Current game state :returns: Rich panel with move history .. py:method:: create_player_hand_panel(game_state, player) Create a panel showing a player's hand. :param game_state: Current game state :param player: Player whose hand to display :returns: Rich panel with player's hand .. py:method:: display_final_results(final_state) Display 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) Display the game state using rich UI. :param state_data: State data in various formats :returns: True if display was successful, False otherwise .. py:method:: display_welcome() Display welcome message. .. py:method:: extract_game_state(state_data) Extract DominoesState from various input formats. :param state_data: State data in various formats :returns: DominoesState instance or None if extraction fails .. py:method:: run_game_with_ui(agent, delay = 1.0) Run a complete 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, player) Display a move being made. Shows a formatted message indicating which player made which move, whether it's playing a tile or passing. :param move: The move being made ("pass" or DominoMove) :type move: Union[DominoMove, str] :param player: Player making the move ("player1" or "player2") :type player: str :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 ("player1" or "player2") :type player: str :param message: Custom message to display. Defaults to "Thinking...". :type message: str, optional :returns: None