haive.games.mafia.example¶

Example implementation and runner for the Mafia game.

This module provides a complete example of how to set up and run a Mafia game, including:

  • Game configuration and initialization

  • Player setup with role assignment

  • Game execution with visualization

  • Debug logging and error handling

  • Command-line interface for game parameters

Examples

To run a game from the command line: ```bash python example.py –players 7 –days 3 –debug

To run programmatically:python

from mafia.example import run_mafia_game run_mafia_game(player_count=7, max_days=3, debug=True) ```

Functions¶

main()

Main entry point for command-line execution.

run_mafia_game([player_count, max_days, debug])

Run a complete Mafia game simulation with visualization.

Module Contents¶

haive.games.mafia.example.main()¶

Main entry point for command-line execution.

haive.games.mafia.example.run_mafia_game(player_count=5, max_days=3, debug=True)¶

Run a complete Mafia game simulation with visualization.

This function sets up and executes a full Mafia game, handling:
  • Player creation and role assignment

  • Game state initialization

  • Turn-based gameplay execution

  • State visualization

  • Game end conditions

Parameters:
  • player_count (int) – Total number of players including narrator. Must be at least 4 (3 players + narrator). Defaults to 5.

  • max_days (int) – Maximum number of in-game days before forcing game end. Defaults to 3.

  • debug (bool) – Enable debug mode for detailed logging. Defaults to True.

Raises:
  • ValueError – If player_count is less than 4.

  • Exception – If game setup or execution fails.

Return type:

None