A deterministic strategy card game engine
Try in Colab • Quick Start • Features • Project Structure • Documentation • Contributing
Want to build an AI agent for Essence Wars? Jump right in — no setup required:
Essence Wars is a strategic two-player card game engine with a focus on:
Full-featured Tauri desktop client with Human vs AI, Spectator mode, Replays, and Deck Builder.
Play Essence Wars directly in Claude Code via MCP (Model Context Protocol):
# 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
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.
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"
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 |
Essence Wars is organized as a layered Rust monorepo with Python ML bindings on top. From bottom to top:
data/.CardId, PlayerId, Slot), keyword rules (Rush, Guard, Lethal, …), card database, and static config.GameEngine facade exposes apply_action, get_legal_actions, and is_terminal. State mutations flow through a non-recursive effect queue for deterministic trigger ordering.GameClient wraps the engine with event emission (creature spawned/damaged/killed), state diffing for efficient UI updates, and action history for replays.For the full design walkthrough see docs/development/architecture.md.
| 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.
| 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.
# 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
Contributions are welcome! This project uses:
Each crate has its own CLAUDE.md with AI-developer context and README.md with human contributor documentation.
# 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
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}
}
MIT License — see LICENSE for details.
Built with Rust, Svelte, and PyTorch
Designed for humans and AIs alike