haive.games.checkers.ui ======================= .. py:module:: haive.games.checkers.ui .. autoapi-nested-parse:: Checkers game UI module. This module provides a rich text-based UI for the checkers game, including: - Beautiful board visualization with colors - Game information display - Move history tracking - Captured pieces visualization - Position analysis display - Game status and winner announcements - Move and thinking animations The UI uses the rich library to create a visually appealing terminal interface that makes the game more engaging and easier to follow. Classes ------- .. autoapisummary:: haive.games.checkers.ui.CheckersUI Module Contents --------------- .. py:class:: CheckersUI Rich UI for beautiful checkers game visualization. This class provides a visually appealing terminal UI for checkers games, with styled components, animations, and comprehensive game information. Features: - Colorful board display with piece symbols - Move history panel - Captured pieces tracking - Game status and information - Position analysis display - Move and thinking animations - Game over screen .. 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 .. attribute:: pieces Unicode symbols for different piece types :type: dict .. attribute:: game_log Log of game events :type: List[str] .. attribute:: move_count Counter for moves :type: int .. attribute:: start_time Game start time :type: datetime .. rubric:: Examples >>> ui = CheckersUI() >>> state = CheckersState.initialize() >>> ui.display_state(state) # Display the initial board >>> >>> # Show thinking animation during move generation >>> ui.show_thinking("red") >>> >>> # Display a move >>> move = CheckersMove(from_position="a3", to_position="b4", player="red") >>> ui.show_move(move) Initialize the checkers UI. Sets up the console, layout, color schemes, piece symbols, and tracking variables for the UI. .. py:method:: display_state(state, message = '') Display the complete game state. Updates and displays all UI components with the current game state. :param state: Current game state :type state: CheckersState :param message: Custom message for the footer. Defaults to "". :type message: str, optional .. rubric:: Examples >>> ui = CheckersUI() >>> state = CheckersState.initialize() >>> ui.display_state(state) >>> >>> # Display with a custom message >>> ui.display_state(state, "Red is thinking...") .. py:method:: show_game_over(state) Show game over screen. Displays a game over message with the winner when the game ends. :param state: Final game state :type state: CheckersState .. rubric:: Examples >>> ui = CheckersUI() >>> state = CheckersState(game_status="game_over", winner="red") >>> ui.show_game_over(state) # Shows "RED WINS!" message .. py:method:: show_move(move) Show move animation. Displays a brief animation/message when a move is made. :param move: The move that was made :type move: CheckersMove .. rubric:: Examples >>> ui = CheckersUI() >>> move = CheckersMove(from_position="a3", to_position="b4", player="red") >>> ui.show_move(move) # Shows move message .. py:method:: show_thinking(player) Show thinking animation. Displays a spinner animation while a player is thinking about a move. :param player: Player who is thinking ("red" or "black") :type player: str .. rubric:: Examples >>> ui = CheckersUI() >>> ui.show_thinking("red") # Shows a spinner for red's thinking