games.among_us.demo¶
Among Us social deduction game demo using the Haive framework.
This module demonstrates an implementation of the popular social deduction game Among Us, where crewmates try to complete tasks while impostors attempt to eliminate them. The game features AI-powered players that engage in discussion, voting, and strategic deception.
- The demo showcases:
Multi-player social deduction gameplay with AI agents
Task completion and sabotage mechanics
Emergency meetings and discussion phases
Voting system with accusations and defenses
Rich terminal UI with game state visualization
Different AI personalities (suspicious, trusting, analytical)
Victory conditions for both crewmates and impostors
- Game Flow:
Players are assigned roles (crewmate or impostor)
Crewmates complete tasks while impostors sabotage
Emergency meetings are called when bodies are found
Players discuss and vote to eject suspected impostors
Game ends when all tasks complete or impostors outnumber crew
- Usage:
- Basic game (5 players, 1 impostor):
$ python demo.py
- Custom configuration:
$ python demo.py –players 8 –impostors 2 –difficulty hard
- With specific map:
$ python demo.py –map skeld –tasks 10
Examples
>>> # Run a standard Among Us game
>>> from haive.games.among_us.demo import run_among_us_demo
>>> run_among_us_demo(num_players=7, num_impostors=2)
Functions¶
|
Format an action for display. |
|
Get color for a player role. |
|
Process a meeting's discussion phase with enhanced visibility. |
|
Process a meeting's discussion phase with enhanced UI. |
|
Process a single player's turn with enhanced visibility into AI thoughts. |
|
Process a single player's turn with enhanced UI. |
|
Process random events that might occur during the task phase. |
|
Process random events that might occur during the task phase with enhanced UI. |
|
Process a meeting's voting phase with enhanced visibility. |
|
Process a meeting's voting phase with enhanced UI. |
|
Run a demo of the Among Us game with AI agents and enhanced visibility. |
Module Contents¶
- games.among_us.demo.format_action(move, verbose=False)¶
Format an action for display.
- games.among_us.demo.get_role_color(role)¶
Get color for a player role.
- games.among_us.demo.process_meeting_discussion(agent, state, console, interactive, speed)¶
Process a meeting’s discussion phase with enhanced visibility.
- Parameters:
agent – The AmongUsAgent instance
state – Current game state
console – Rich console for display
interactive – Whether in interactive mode
speed – Simulation speed multiplier
- Returns:
Updated state
- games.among_us.demo.process_meeting_discussion_enhanced(agent, state, ui, interactive, speed)¶
Process a meeting’s discussion phase with enhanced UI.
- Parameters:
agent – The AmongUsAgent instance
state – Current game state
ui – Enhanced UI instance
interactive – Whether in interactive mode
speed – Simulation speed multiplier
- Returns:
Updated state
- games.among_us.demo.process_player_turn(agent, state, player_id, console, interactive, speed)¶
Process a single player’s turn with enhanced visibility into AI thoughts.
- games.among_us.demo.process_player_turn_enhanced(agent, state, player_id, ui, interactive, speed)¶
Process a single player’s turn with enhanced UI.
- games.among_us.demo.process_random_events(agent, state, console, interactive, speed)¶
Process random events that might occur during the task phase.
- games.among_us.demo.process_random_events_enhanced(agent, state, ui, interactive, speed)¶
Process random events that might occur during the task phase with enhanced UI.
- Parameters:
agent – The AmongUsAgent instance
state – Current game state
ui – Enhanced UI instance
interactive – Whether in interactive mode
speed – Simulation speed multiplier
- Returns:
Updated state
- games.among_us.demo.process_voting_phase(agent, state, console, interactive, speed)¶
Process a meeting’s voting phase with enhanced visibility.
- Parameters:
agent – The AmongUsAgent instance
state – Current game state
console – Rich console for display
interactive – Whether in interactive mode
speed – Simulation speed multiplier
- Returns:
Updated state
- games.among_us.demo.process_voting_phase_enhanced(agent, state, ui, interactive, speed)¶
Process a meeting’s voting phase with enhanced UI.
- Parameters:
agent – The AmongUsAgent instance
state – Current game state
ui – Enhanced UI instance
interactive – Whether in interactive mode
speed – Simulation speed multiplier
- Returns:
Updated state
- games.among_us.demo.run_among_us_demo(player_count=6, impostor_count=1, map_name='skeld', save_path=None, load_path=None, interactive=True, max_rounds=15, speed=1.0, use_enhanced_ui=True)¶
Run a demo of the Among Us game with AI agents and enhanced visibility.
- Parameters:
player_count (int) – Number of players (4-10)
impostor_count (int) – Number of impostors (1-3)
map_name (str) – Name of map to use
save_path (str) – Path to save game at the end
load_path (str) – Path to load a saved game
interactive (bool) – Whether to run in interactive mode
max_rounds (int) – Maximum number of rounds
speed (float) – Simulation speed multiplier
use_enhanced_ui (bool) – Whether to use the enhanced UI (recommended)