games.among_us.enhanced_ui¶

Enhanced Rich UI module for Among Us game visualization.

This module provides an enhanced rich console UI for visualizing the Among Us game, with better styling, animated visualizations, and improved game information display.

Classes¶

EnhancedAmongUsUI

Enhanced UI for Among Us game with rich terminal graphics.

Module Contents¶

class games.among_us.enhanced_ui.EnhancedAmongUsUI(console=None)¶

Enhanced UI for Among Us game with rich terminal graphics.

This class provides a visually appealing terminal UI for Among Us games, with styled components, animations, and comprehensive game information.

Features:
  • Beautiful game map visualization with colored squares

  • Animated transitions between game states

  • Detailed player status display

  • Vent and sabotage system visualization

  • Meeting and voting interfaces

  • Game over screens with detailed statistics

Initialize the UI.

Parameters:

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

animate_move(move, state_before, state_after, player_id, delay=0.5)¶

Animate a move being made.

Parameters:
Returns:

None

Return type:

None

create_game_info_panel(state)¶

Create a panel with general game information.

Parameters:

state (haive.games.among_us.state.AmongUsState) – Current game state

Returns:

Rich panel containing game information

Return type:

rich.panel.Panel

create_game_over_panel(state)¶

Create a panel for the game over screen.

Parameters:

state (haive.games.among_us.state.AmongUsState) – Current game state

Returns:

Rich panel for game over

Return type:

rich.panel.Panel

create_layout(state, player_id=None, legal_moves=None)¶

Create the complete layout for the game UI.

Parameters:
Returns:

Complete rich layout

Return type:

rich.layout.Layout

Create a panel showing legal moves.

Parameters:

legal_moves (list[dict[str, Any]]) – List of legal moves for the player

Returns:

Rich panel showing legal moves

Return type:

rich.panel.Panel

create_map_visualization(state, player_id=None)¶

Create a visual representation of the map with rooms, vents, and players.

Parameters:
Returns:

Rich panel containing the map visualization

Return type:

rich.panel.Panel

create_meeting_panel(state)¶

Create a panel for the meeting phase.

Parameters:

state (haive.games.among_us.state.AmongUsState) – Current game state

Returns:

Rich panel for the meeting

Return type:

rich.panel.Panel

create_other_players_panel(state, player_id)¶

Create a panel showing information about other players.

Parameters:
Returns:

Rich panel containing other player information

Return type:

rich.panel.Panel

create_player_info_panel(state, player_id)¶

Create a panel with detailed information about the player.

Parameters:
Returns:

Rich panel containing player information

Return type:

rich.panel.Panel

create_sabotage_panel(state, player_id=None)¶

Create a panel showing active sabotage information if any.

Parameters:
Returns:

Rich panel for sabotage or None if no active sabotage

Return type:

rich.panel.Panel | None

display_final_results(final_state)¶

Display enhanced final game results.

Parameters:

final_state (Any) – Final game state

Returns:

None

Return type:

None

display_state(state_data, player_id=None, legal_moves=None)¶

Display the game state using enhanced rich UI.

Parameters:
  • state_data (Any) – State data in various formats

  • player_id (str | None) – Optional ID of the player whose perspective to show

  • legal_moves (list[dict[str, Any]] | None) – Optional list of legal moves for the player

Returns:

True if display was successful, False otherwise

Return type:

bool

display_welcome()¶

Display welcome message and game introduction.

Returns:

None

Return type:

None

extract_game_state(state_data)¶

Extract AmongUsState from various input formats.

Parameters:

state_data (Any) – State data in various formats

Returns:

AmongUsState instance or None if extraction fails

Return type:

haive.games.among_us.state.AmongUsState | None

run_among_us_game(agent, delay=1.0)¶

Run a complete Among Us game with UI visualization.

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

  • delay (float) – Delay between game states

Returns:

Final game state

Return type:

haive.games.among_us.state.AmongUsState

show_thinking(player_id, message='Thinking...')¶

Display a thinking animation for the player.

Parameters:
  • player_id (str) – ID of the player who is thinking

  • message (str) – Message to display during thinking

Returns:

None

Return type:

None