Skip to main content

A flexible, extensible Werewolf game engine for Python

Project description

WereWolf Engine

A flexible, extensible Werewolf (Mafia) game engine for Python.

Tests PyPI version

Features

  • 6 built‑in roles: Villager, Werewolf, Seer, Doctor, Witch, Hunter
  • Plugin system for custom roles
  • Full night/day cycle with priority and conflict resolution
  • Voting system with majority & tie handling
  • Event bus for UI integration
  • Save/restore game state (to/from dict)
  • 23+ tests covering all features

Installation

pip install werewolf-engine

Quick Example

from werewolf_engine import Game, GameConfig

config = GameConfig(role_counts={"villager": 3, "werewolf": 2, "seer": 1, "doctor": 1, "witch": 1, "hunter": 1})
game = Game(["Alice", "Bob", "Charlie", "Diana", "Eve", "Frank", "Grace", "Hank", "Ivy"], config)
game.start()

# Drive the game with your own UI (bot, web, CLI...)
while game.phase != Phase.END:
    if game.phase == Phase.NIGHT:
        actor = game.night_manager.current_actor
        if actor:
            targets = game.night_manager.get_available_targets(actor)
            # get user choice, then:
            game.night_action(actor.id, chosen_target.id)

Documentation

Full documentation is available in English and Persian:

Learn about roles, events, API reference, and how to contribute.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

werewolf_engine-0.1.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

werewolf_engine-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file werewolf_engine-0.1.0.tar.gz.

File metadata

  • Download URL: werewolf_engine-0.1.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for werewolf_engine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e511771540a5d60e451adfb958ac2fcc804dd221bbd237cd9139b78c35d73dc3
MD5 cae726a32c207817d3f87af90940572a
BLAKE2b-256 6751b93d94082be1e401a71c1af6eedec1705fbb10eac122d23407b17d7676ac

See more details on using hashes here.

File details

Details for the file werewolf_engine-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for werewolf_engine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a9df7ad3c9893c8242f06b98626a54ae1012bacc484db3d44eb027e64306555
MD5 eef1164d29ade1b666d301230a964f8b
BLAKE2b-256 fd4fd5e18768cea446cb2007565ed8d62de1acb0fc7b796e83256632594cb767

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page