haive.games.connect4.ui ======================= .. py:module:: haive.games.connect4.ui .. autoapi-nested-parse:: Connect4 rich UI visualization module. This module provides a visually appealing terminal UI for Connect4 games, with styled components, animations, and comprehensive game information. It uses the Rich library to create a console-based UI with: - Colorful board display with piece symbols - Move history panel - Game status and information - Position analysis display - Move and thinking animations .. rubric:: Example >>> from haive.games.connect4.ui import Connect4UI >>> from haive.games.connect4.state import Connect4State >>> >>> ui = Connect4UI() >>> state = Connect4State.initialize() >>> ui.display_state(state) # Display the initial board >>> >>> # Show thinking animation for player move >>> ui.show_thinking("red") >>> >>> # Display a move >>> from haive.games.connect4.models import Connect4Move >>> move = Connect4Move(column=3) >>> ui.show_move(move, "red") Classes ------- .. autoapisummary:: haive.games.connect4.ui.Connect4UI Module Contents --------------- .. py:class:: Connect4UI Rich UI for beautiful Connect4 game visualization. This class provides a visually appealing terminal UI for Connect4 games, with styled components, animations, and comprehensive game information. Features: - Colorful board display with piece symbols - Move history panel - Game status and information - Position analysis display - Move and thinking animations .. 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 = Connect4UI() >>> state = Connect4State.initialize() >>> ui.display_state(state) # Display the initial board Initialize the Connect4 UI with default settings. .. py:method:: display_state(state) Display the current game state with rich formatting. Renders the complete game state including board, game info, analysis, and move history in a formatted layout. :param state: Current game state (Connect4State or dict) :type state: Union[Connect4State, dict] :returns: None .. rubric:: Example >>> ui = Connect4UI() >>> state = Connect4State.initialize() >>> ui.display_state(state) .. py:method:: show_game_over(winner = None) Display game over message with result. Shows a game over panel with the winner highlighted in their color, or indicating a draw if there's no winner. :param winner: Winning player or None for a draw. Defaults to None. :type winner: Optional[str], optional :returns: None .. rubric:: Example >>> ui = Connect4UI() >>> ui.show_game_over("red") # Red player wins >>> ui.show_game_over(None) # Draw .. py:method:: show_move(move, player) Display a move animation. Shows a formatted message indicating which player made which move, with color-coded player name and piece symbol. :param move: The move being made :type move: Connect4Move :param player: Player making the move ("red" or "yellow") :type player: str :returns: None .. rubric:: Example >>> ui = Connect4UI() >>> move = Connect4Move(column=3) >>> ui.show_move(move, "red") .. 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 ("red" or "yellow") :type player: str :param message: Custom message to display. Defaults to "Thinking...". :type message: str, optional :returns: None .. rubric:: Example >>> ui = Connect4UI() >>> ui.show_thinking("red", "Analyzing position...")