haive.games.fox_and_geese.rich_ui

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

FoxAndGeeseRichUI

Enhanced Rich UI for Fox and Geese game visualization.

Module Contents

class haive.games.fox_and_geese.rich_ui.FoxAndGeeseRichUI(console=None)[source]

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

console

Rich console for output

Type:

Console

colors

Color schemes for different UI elements

Type:

dict

Initialize the UI.

Parameters:

console (rich.console.Console | None) – Optional Rich console instance

animate_move(state_before, state_after, delay=0.5)[source]

Animate a move being made.

Shows a smooth transition between the before and after states with visual indicators of what changed.

Parameters:
Returns:

None

Return type:

None

create_analysis_panel(game_state)[source]

Create an enhanced panel showing the latest analysis.

Parameters:

game_state (haive.games.fox_and_geese.state.FoxAndGeeseState) – Current game state

Returns:

Rich panel with detailed analysis

Return type:

rich.panel.Panel

create_board_table(game_state, highlight_positions=None, capture_position=None)[source]

Create an enhanced visual representation of the board.

Parameters:
Returns:

Rich table representing the board

Return type:

rich.table.Table

create_game_info_panel(game_state)[source]

Create an enhanced panel with game information.

Parameters:

game_state (haive.games.fox_and_geese.state.FoxAndGeeseState) – Current game state

Returns:

Rich panel with detailed game info

Return type:

rich.panel.Panel

create_layout(game_state, highlight_positions=None, capture_position=None, legal_moves=None)[source]

Create the enhanced complete rich UI layout.

Parameters:
Returns:

Complete rich layout

Return type:

rich.layout.Layout

Create a panel showing legal moves for the current player.

Parameters:
Returns:

Rich panel with legal moves info

Return type:

rich.panel.Panel

create_move_history_panel(game_state)[source]

Create an enhanced panel showing move history.

Parameters:

game_state (haive.games.fox_and_geese.state.FoxAndGeeseState) – Current game state

Returns:

Rich panel with detailed move history

Return type:

rich.panel.Panel

display_final_results(final_state)[source]

Display enhanced final game results.

Parameters:

final_state (Any) – Final game state

Return type:

None

display_game_with_animation(state_sequence, delay=1.0)[source]

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.

Parameters:
Returns:

None

Return type:

None

display_state(state_data, highlight_positions=None, capture_position=None, legal_moves=None)[source]

Display the game state using enhanced rich UI.

Parameters:
Returns:

True if display was successful, False otherwise

Return type:

bool

display_welcome()[source]

Display welcome message.

Return type:

None

extract_game_state(state_data)[source]

Extract FoxAndGeeseState from various input formats.

Parameters:

state_data (Any) – State data in various formats

Returns:

FoxAndGeeseState instance or None if extraction fails

Return type:

haive.games.fox_and_geese.state.FoxAndGeeseState | None

run_fox_and_geese_game(agent, delay=1.0)[source]

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.

Parameters:
  • agent – The game agent that manages the game logic

  • delay (float) – Delay in seconds between game states

Returns:

Final game state

Return type:

haive.games.fox_and_geese.state.FoxAndGeeseState

show_move(move, state_before, state_after)[source]

Display an animated move being made.

Shows the move with highlighting of the relevant positions.

Parameters:
Returns:

None

Return type:

None

show_thinking(player, message='Thinking...')[source]

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.

Parameters:
  • player (str) – Current player (“fox” or “geese”)

  • message (str, optional) – Custom message to display. Defaults to “Thinking…”.

Returns:

None

Return type:

None