haive.games.nim.ui¶
Rich UI implementation for the Nim game.
This module provides a Rich-based UI for visualizing and interacting with the Nim game. It includes a NimUI class that handles visualization of the game state, piles, and game information.
Classes¶
Rich terminal UI for the Nim game. |
Module Contents¶
- class haive.games.nim.ui.NimUI[source]¶
Rich terminal UI for the Nim game.
This class provides methods for visualizing the Nim game state using the Rich library. It includes methods for displaying the game board, piles, game information, and analysis.
Initialize the UI with a Rich console if available.
- create_analysis_panel(state)[source]¶
Create a panel showing the latest analysis if available.
- Parameters:
state (haive.games.nim.state.NimState) – The current game state.
- Returns:
A Rich panel containing analysis information, or None if no analysis.
- Return type:
Optional[Panel]
- create_header(state)[source]¶
Create header panel with game info.
- Parameters:
state (haive.games.nim.state.NimState) – The current game state.
- Returns:
A Rich panel containing the game header information.
- Return type:
Panel
- create_layout(state)[source]¶
Create the complete layout for the game display.
- Parameters:
state (haive.games.nim.state.NimState) – The current game state.
- Returns:
A Rich layout for the complete game display.
- Return type:
Layout
- create_moves_table(state)[source]¶
Create a table showing move history.
- Parameters:
state (haive.games.nim.state.NimState) – The current game state.
- Returns:
A Rich table containing the move history.
- Return type:
Table
- create_piles_panel(state)[source]¶
Create a panel showing the piles of stones.
- Parameters:
state (haive.games.nim.state.NimState) – The current game state.
- Returns:
A Rich panel containing visualizations of the piles.
- Return type:
Panel