Skip to main content

A Pythonic, structured data engine for Twilight Imperium 4th Edition

Project description

TI4 Rules Engine

A Pythonic, structured data engine for Twilight Imperium 4th Edition. Tracks game state, provides rule references, and calculates player options from a live AsyncTI4 Discord bot game.

Analyse a game in one command

No installation required — just uvx:

uvx --from ti4-rules-engine ti4-analyze <game_name>

Replace <game_name> with the name of your AsyncTI4 game (the identifier shown by the bot, e.g. pbd22295):

uvx --from ti4-rules-engine ti4-analyze pbd22295

The command fetches the live game snapshot from the AsyncTI4 API and prints:

  • Current round, phase, and active player
  • Per-player summary: faction, VP, resources, planets, technologies, and leaders
  • Every legal action available to each player under TI4 rules right now
  • Reachable systems for each fleet (movement + anomaly rules applied)

Note: uvx --from ti4-rules-engine requires the package to be published on PyPI. Until then, clone the repo and use the local install instead:

git clone --recurse-submodules https://github.com/adam133/ti4-rules-engine
cd ti4-rules-engine
uv tool install .
ti4-analyze pbd22295

Development note: this repository reads game data from a git submodule (data/TI4_map_generator_bot), so local development requires cloning with submodules (or running git submodule update --init --recursive in an existing clone).

What it shows

============================================================
Game:   pbd22295   Round: 3   Phase: action
Active: sargun
============================================================

  sargun [ACTIVE]
    Faction:  Nekro Virus
    VP:       5
    TG:       3  |  Commodities: 0
    Tokens:   3 tactical / 5 fleet / 2 strategy
    Planets:  8 controlled, 2 exhausted
    ...
    Actions available:
      • tactical_action
      • component_action
      • strategic_action

Further reading

  • docs/implementation.md — module reference and API examples (game session setup, modifier system, combat simulation, scoring, movement, opponent public info)
  • docs/contributing.md — local dev setup, running tests, and project roadmap

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

ti4_rules_engine-0.2.0.tar.gz (469.7 kB view details)

Uploaded Source

Built Distribution

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

ti4_rules_engine-0.2.0-py3-none-any.whl (81.8 kB view details)

Uploaded Python 3

File details

Details for the file ti4_rules_engine-0.2.0.tar.gz.

File metadata

  • Download URL: ti4_rules_engine-0.2.0.tar.gz
  • Upload date:
  • Size: 469.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ti4_rules_engine-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1d38e8e5d283d6d45fdc750f957d1f7dd496534889de590a019e0171155c3fb2
MD5 efa3b6af7f490d89504f2c7095df55a5
BLAKE2b-256 c2743ae31c69fa907be19d9a46798044bdb3342946d79fa273197f9430aea7d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ti4_rules_engine-0.2.0.tar.gz:

Publisher: publish.yml on adam133/ti4-rules-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ti4_rules_engine-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ti4_rules_engine-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 460861b46bb6c456c7030c9aa83b991fea860dfb79a7cdbf2ff22c061a2693a7
MD5 f96a1ccf885fd714f260580240f55e29
BLAKE2b-256 b7dd34e33687e19f35aec1dff114036288bf0d5fb61b745455c68686b46f1858

See more details on using hashes here.

Provenance

The following attestation bundles were made for ti4_rules_engine-0.2.0-py3-none-any.whl:

Publisher: publish.yml on adam133/ti4-rules-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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