Skip to main content

High-performance card game environment

Project description

Essence Wars

A deterministic strategy card game engine

Try in ColabQuick StartFeaturesProject StructureDocumentationContributing


Try it in Google Colab

Want to build an AI agent for Essence Wars? Jump right in — no setup required:

Notebook Description
Open In Colab Quickstart — Explore the game engine, play games, see the API
Open In Colab Train a PPO Agent — Build and train a neural network to play
Open In Colab Evaluate & Benchmark — Test agents against built-in bots

What is Essence Wars?

Essence Wars is a strategic two-player card game engine with a focus on:

  • Perfect Information (Engine) — The core engine is fully open: bots and ML agents see all cards, hands, and decks. In the desktop UI, opponent hands are hidden for a more natural play experience. Victory comes from outthinking your opponent, not luck.
  • Deterministic Execution — Seeded RNG ensures every game is reproducible.
  • Lane-Based Combat — Creatures occupy board positions, creating spatial strategy alongside card selection.

Gameplay

Features

Desktop Application

Full-featured Tauri desktop client with Human vs AI, Spectator mode, Replays, and Deck Builder.

Main Menu Spectator Mode Deck Builder

AI & Machine Learning

  • Multiple Bot Types — Random, Greedy (28 tunable weights), MCTS, Alpha-Beta search
  • Python ML Framework — Gymnasium/PettingZoo environments, PPO, AlphaZero, Game Transformer
  • Training Infrastructure — Callbacks, experiment tracking, W&B integration

Claude Code Integration

Play Essence Wars directly in Claude Code via MCP (Model Context Protocol):

  • Natural language game control
  • AI move recommendations with analysis
  • Live game visualization in Tauri UI (Launch the Essence Wars UI App, and ask Claude to sync, watch her play the game live in the App!)

Quick Start

Play the Desktop App

# Clone and build
git clone https://github.com/christianWissmann85/essence-wars
cd essence-wars
cargo build --release

# Launch the UI
cd crates/essence-wars-ui
pnpm install && pnpm tauri:dev

Train Your Own AI Agent

The fastest way to get started is the Colab notebooks above. For local development:

# Install Python package
uv pip install essence-wars[train]

# 1. Train a PPO agent
uv run python python/scripts/training/ppo.py --timesteps 500000

# 2. Export to ONNX (the training script prints the exact command to use)
uv run python -m essence_wars.agents.export_onnx \
  experiments/ppo/<your_run>/best_model.pt \
  ~/.essence-wars/agents/my_agent.onnx

# 3. Play against it in the CLI
cargo run --release --bin arena -- \
  --bot1 greedy --deck1 architect_fortify \
  --bot2 "neural:$HOME/.essence-wars/agents/my_agent.onnx" --deck2 archon_burst \
  --games 100

Exported .onnx agents in ~/.essence-wars/agents/ are also automatically available in the desktop app's bot selection menu. See the Python README for the full guide.

Play via Claude Code (MCP)

Add to your .mcp.json:

{
  "mcpServers": {
    "essence-wars": {
      "command": "./target/release/essence-wars-mcp"
    }
  }
}

Then in Claude Code: "Start a game with the Iron Wall deck against Swarm Aggro"

Project Structure

essence-wars/
├── crates/
│   ├── cardgame/           # Core game engine (Rust)
│   ├── essence-wars-ui/    # Desktop app (Tauri + Svelte)
│   └── essence-wars-mcp/   # MCP server for Claude Code
├── python/                 # ML agents & training (PyTorch)
├── data/
│   ├── cards/              # Card definitions (YAML)
│   ├── decks/              # Deck definitions (TOML)
│   └── weights/            # Bot weight files
└── docs/                   # Documentation
Component Description README
cardgame High-performance game engine, bots, CLI tools README
essence-wars-ui Cross-platform desktop client README
essence-wars-mcp MCP server for Claude Code README
python ML agents, training, benchmarking README

Architecture

Architecture Diagram

Essence Wars is organized as a layered Rust monorepo with Python ML bindings on top. From bottom to top:

  • Data Layer — Card definitions (YAML), deck compositions (TOML), and bot weight files live under data/.
  • Foundation Layer — Core types (CardId, PlayerId, Slot), keyword rules (Rush, Guard, Lethal, …), card database, and static config.
  • Core Game EngineGameEngine facade exposes apply_action, get_legal_actions, and is_terminal. State mutations flow through a non-recursive effect queue for deterministic trigger ordering.
  • Client API LayerGameClient wraps the engine with event emission (creature spawned/damaged/killed), state diffing for efficient UI updates, and action history for replays.
  • User Interfaces — Three independent consumers of the same engine: the Tauri/Svelte 5 desktop app, the MCP server (JSON-RPC for Claude Code), and the Python ML bindings (PyO3/FFI for Gymnasium & PyTorch).

For the full design walkthrough see docs/development/architecture.md.


Three Factions

Faction Identity Keywords
Argentum Combine Defense & durability Guard, Shield, Fortify, Piercing
Symbiote Circles Aggressive tempo Rush, Lethal, Regenerate, Volatile
Obsidion Syndicate Burst damage Lifesteal, Stealth, Quick, Charge

Plus Neutral cards and 12 unique Commanders with passive abilities.

Documentation

Game Design

ML & AI

Development

Performance

Metric Value
Random games ~23,700/sec
Greedy bot games ~1,500/sec
MCTS (100 sims) ~18.6 ms/move
MCTS parallel (8 trees) ~9.3 ms/move
Alpha-Beta depth 6 ~1.4 ms/move
Engine state clone ~404 ns
State tensor encode ~157 ns
Greedy evaluate ~5.6 ns
Zobrist hash ~6.8 ns
Apply action (attack) ~190 ns

Run cargo bench -p cardgame for the full suite.

Commands

# Build & Test
cargo build --release                    # Full workspace
cargo nextest run --status-level=fail    # Rust tests
uv run pytest python/tests               # Python tests

# Lint
cargo clippy                             # Rust lint
uv run mypy python/essence_wars          # Python types
pnpm run check                           # Svelte/TS (in UI crate)

# Game Tools
cargo run --release --bin arena --       # Bot matches
cargo run --release --bin validate --    # Quick balance check
cargo run --release --bin benchmark --   # Thorough analysis
cargo run --release --bin swiss --       # Tournament mode

Contributing

Contributions are welcome! This project uses:

  • Rust for the core engine and desktop backend
  • Svelte 5 (with runes) for the desktop frontend
  • Python for ML agents and training

Each crate has its own CLAUDE.md with AI-developer context and README.md with human contributor documentation.

Development Setup

# Rust
cargo build --release

# Python (using uv)
uv sync --all-groups
uv run pytest python/tests

# UI (using pnpm)
cd crates/essence-wars-ui
pnpm install
pnpm tauri:dev

Citation

If you use Essence Wars in your research, please cite:

@software{essence_wars,
  title = {Essence Wars: A High-Performance Card Game Environment for RL Research},
  author = {Wissmann, Christian},
  year = {2025},
  url = {https://github.com/christianWissmann85/essence-wars}
}

License

MIT License — see LICENSE for details.


Built with Rust, Svelte, and PyTorch
Designed for humans and AIs alike

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

essence_wars-0.10.1.tar.gz (729.2 kB view details)

Uploaded Source

Built Distributions

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

essence_wars-0.10.1-cp313-cp313-win_amd64.whl (943.8 kB view details)

Uploaded CPython 3.13Windows x86-64

essence_wars-0.10.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

essence_wars-0.10.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

essence_wars-0.10.1-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

essence_wars-0.10.1-cp313-cp313-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

essence_wars-0.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

essence_wars-0.10.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

essence_wars-0.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

essence_wars-0.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

essence_wars-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

essence_wars-0.10.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

File details

Details for the file essence_wars-0.10.1.tar.gz.

File metadata

  • Download URL: essence_wars-0.10.1.tar.gz
  • Upload date:
  • Size: 729.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for essence_wars-0.10.1.tar.gz
Algorithm Hash digest
SHA256 658412b981675fec33d62df30fb4d877950f310d11baddf884fec1383940a6fb
MD5 c2a924d964df408b5e54564834666459
BLAKE2b-256 40bdd59096b376a67263cccd428657b34fd59dd73ac3f4c01bfacab5110a96b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1.tar.gz:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 33fd37567dd2f429f316eb2ba460446dee12881aae4c8477be33c163d4f772e9
MD5 ce82c6ee1aea3122496a503243d96f53
BLAKE2b-256 084c593a9f0f75c88bb4bdb5356d97a211d13b25c9e163e8a4c3757291353c9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e24fe65d4f6d5520d72f19c20327a1c57a217ae700df72c8bd1fe7d23d9993e2
MD5 463d7fd3012f68c62ee9c0da5d7ef066
BLAKE2b-256 5b85926d9ba77a50170f19b8711f923e06791b20d5882e038a2db5e17387d9ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c50af8bf3089089c2d4f6912e3d8a9f821904d41af7381af37e136202105d81e
MD5 8b66d7d5451b461e5e0b59afa8913e8a
BLAKE2b-256 92beb44e8d79638f451d14a84b39ea9b2938ddb63a0515f874bacc792fca859f

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0028de5a34aa991f7d6faf3eb6aaba70b9bc0924892c17414235761c4a44d7a2
MD5 4e494a90dfaf14cd9ab32b4131fbd23a
BLAKE2b-256 913d1e79f7f502eafcddcb5c09181fec4b5361d80e380b5959eefcdddd6071f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d0f8bc3de70a7db689cf759eb36490345114026e08e0e8989489d71ce3ddbfd3
MD5 b4dd4d5c95b7a1d26238fe55cfb5fd1f
BLAKE2b-256 696e91074ef8cb62769a331560ce84df6996c05344f935d6253a670df3ff4503

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e672fc14ae45e2e904f2c61f8a776852528e9f02b105d367093557279f1a96d
MD5 cf013149ba662d43aad758a375014219
BLAKE2b-256 fa42eeb8ca6b82633cf66d37edebe83a985f11b2f0350ae3039d4f09c16719c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b78648f14d0504b3b23b46f579c1ce46434ef1059062af75a813281c800f4cc9
MD5 ba4d2157faf94521fce50c075a64f472
BLAKE2b-256 3fa1b93253fab27d7c2ecdae66fd9a0a34ca515dbbf16f4caf0810950b8b8cde

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eee7a771c79e634865549d77e0d801dd126f02691397bd919284d641923ecb8f
MD5 2061a986ab53b180e7601282596bd75b
BLAKE2b-256 29ca601eebeef5b165dd782f217ef03b08127f6ab4041275494872e25598b53f

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c9fac6962f502efa8b339e94f8e23c6770c8b914f18aee6218a721d5a8fbf56a
MD5 e831a822533314ca8e37be181fa00722
BLAKE2b-256 b4904bf5dd78e6463aaffe5162d37ed860ea0cbfd0c5110d0755273c62fd1bb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 faf93ead347b79f466b6a055194a26e90fed1a8701d1688b3764f381aaa8602f
MD5 714560496518c735008f90c8c0cdf96a
BLAKE2b-256 92fc5997e09bcc34180830a8bd187a1cc9c17944cf3a1ad28fa4e419e446a688

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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

File details

Details for the file essence_wars-0.10.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.10.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 91822638fbdb477515d987d0919e26f9cc20c93de266a99a1d57f4fc794f03b8
MD5 9349b9bf88784d0f75042dd16cfd969e
BLAKE2b-256 d59a3a031729b29498d3de86f7f11370ac9e39d504da579a60e0240b48e26709

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.10.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on christianWissmann85/essence-wars

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