A conservative, rules-aware coaching engine for Commander-style tabletop game states.
Project description
EDH Rules Coach
EDH Rules Coach is a local-first, rules-aware coaching engine for Commander-style tabletop game states. It separates two jobs that AI assistants often blur together:
- a rules layer determines which actions and targets are legal; and
- a policy layer ranks legal actions and explains the recommendation.
The project is intentionally conservative. When legality or screen-state confidence cannot be established, it prefers to abstain instead of inventing an action.
This is an independent, community-built project. It is not affiliated with or endorsed by Wizards of the Coast, Scryfall, or the Forge project. See NOTICE.md.
中文说明见 README.zh-CN.md.
Current capabilities
- JSON game-state input and command-line recommendations.
- Conservative fallback action generation when an external engine is unavailable.
- Target validation for permanent types, players, hexproof, shroud, and static protection text.
- Decklist parsing and Commander deck sanity checks.
- Optional local Scryfall bulk-data indexing; no Scryfall dataset is committed.
- Optional Forge integration through a JSON bridge; no Forge source or binaries are committed.
- Heuristic, linear-policy, Forge-prior, and state-policy training/evaluation utilities.
- Screenshot/TTS annotation helpers with a low-confidence abstention gate.
- 130 unit tests.
Project status
This repository is an early public release. The fallback rules are deliberately incomplete and are not a replacement for a full comprehensive-rules engine. For authoritative legality, connect an external engine and provide legal_actions in the input state.
Quick start
Requirements: Python 3.11 or newer. Pillow, NumPy, and headless OpenCV are installed for screenshot and card-image helpers; rules, deck, and text-state workflows otherwise use the Python standard library.
Install a published release from PyPI:
python -m pip install edh-rules-coach
edh-coach --help
Install a development checkout:
git clone https://github.com/stnmftnkgx-rgb/edh-rules-coach.git
cd edh-rules-coach
python -m pip install -e .
edh-coach recommend --state data/sample_state.json --generate-actions --top-k 5
Without installation:
$env:PYTHONPATH = "$PWD\src"
python -m mtg_ai recommend --state data/sample_state.json --generate-actions --top-k 5
Run the test suite:
python -m unittest discover -s tests -v
Run the repository hygiene check:
python scripts/check_repository.py
Build and smoke-test the installable wheel in an isolated environment:
python -m pip wheel . --no-deps --wheel-dir dist
python scripts/smoke_test_wheel.py --wheel-dir dist --fixture data/sample_state.json
Optional card data
Card data is downloaded by each user and remains outside version control:
./scripts/download_card_db.ps1
The downloader uses Scryfall's bulk-data endpoint with an identifying user agent. Review Scryfall's current API documentation and terms before redistributing derived data. This repository does not redistribute card images, bulk JSON, or the generated card-name index.
Optional Forge integration
Forge is a separate GPL-licensed project. Download it from its official repository or releases and place a local runtime under tools/forge-release/, or configure an external JSON rules engine. This repository includes only the small bridge source maintained here; it does not vendor Forge.
./scripts/forge_status.ps1
See docs/architecture.md for the boundary between the coach and external rules engines.
Input contract
The smallest useful state contains players, zones, turn/phase information, and either:
- an authoritative
legal_actionslist; or - enough public information for conservative fallback generation.
Start with data/sample_state.json. Do not include private player information in bug reports.
Validate a state before sending it to the coach or an external engine:
edh-coach validate-state --state data/sample_state.json
edh-coach validate-state --state data/sample_state.json --json
The versioned Draft 2020-12 contract is distributed with the package at src/mtg_ai/schemas/game-state.schema.json. Engine-specific extension fields are allowed, while the required core shape and known field types are checked.
Contributing
Issues and pull requests are welcome. Small legality fixes should normally include focused tests for both the fallback rules path and the Forge bridge path when both are affected. Read CONTRIBUTING.md and SECURITY.md before submitting.
Maintainer release instructions are documented in docs/publishing.md.
License
Copyright 2026 stnmftnkgx-rgb and contributors.
Licensed under the GNU General Public License, version 3 or later. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file edh_rules_coach-0.2.2.tar.gz.
File metadata
- Download URL: edh_rules_coach-0.2.2.tar.gz
- Upload date:
- Size: 101.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
546e9c8fb1c00d83e9dceb749c6dd19f8e7b29f5f323c583c5f508bd4f02cb3c
|
|
| MD5 |
ef17f552184a0e9652ceaf294cb512cd
|
|
| BLAKE2b-256 |
bd81bda529e45b5b4fc789bd8c28197a446de0d26b6b21532001a62342a17071
|
Provenance
The following attestation bundles were made for edh_rules_coach-0.2.2.tar.gz:
Publisher:
publish.yml on stnmftnkgx-rgb/edh-rules-coach
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edh_rules_coach-0.2.2.tar.gz -
Subject digest:
546e9c8fb1c00d83e9dceb749c6dd19f8e7b29f5f323c583c5f508bd4f02cb3c - Sigstore transparency entry: 2162905262
- Sigstore integration time:
-
Permalink:
stnmftnkgx-rgb/edh-rules-coach@5b41b4c02a3bc11c5b2c113417a21a44723cd897 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/stnmftnkgx-rgb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5b41b4c02a3bc11c5b2c113417a21a44723cd897 -
Trigger Event:
release
-
Statement type:
File details
Details for the file edh_rules_coach-0.2.2-py3-none-any.whl.
File metadata
- Download URL: edh_rules_coach-0.2.2-py3-none-any.whl
- Upload date:
- Size: 97.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce09dde4d125c0abbee6710a720fde3fd755f162824a52d545a00408b016b437
|
|
| MD5 |
c428baf0d5587a2f47492b27a70d746c
|
|
| BLAKE2b-256 |
caefd368eb0061037449aea91517b5117719511f37922ce7289fcf0a7ad1f560
|
Provenance
The following attestation bundles were made for edh_rules_coach-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on stnmftnkgx-rgb/edh-rules-coach
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edh_rules_coach-0.2.2-py3-none-any.whl -
Subject digest:
ce09dde4d125c0abbee6710a720fde3fd755f162824a52d545a00408b016b437 - Sigstore transparency entry: 2162905287
- Sigstore integration time:
-
Permalink:
stnmftnkgx-rgb/edh-rules-coach@5b41b4c02a3bc11c5b2c113417a21a44723cd897 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/stnmftnkgx-rgb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5b41b4c02a3bc11c5b2c113417a21a44723cd897 -
Trigger Event:
release
-
Statement type: