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.9.7.tar.gz (705.5 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.9.7-cp313-cp313-win_amd64.whl (926.8 kB view details)

Uploaded CPython 3.13Windows x86-64

essence_wars-0.9.7-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.9.7-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.9.7-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

essence_wars-0.9.7-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.9.7-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.9.7-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.9.7-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.9.7-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.9.7-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.9.7.tar.gz.

File metadata

  • Download URL: essence_wars-0.9.7.tar.gz
  • Upload date:
  • Size: 705.5 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.9.7.tar.gz
Algorithm Hash digest
SHA256 42bbe8040fe6e9ffc6e914c5e48f74d6ea75a5b7cc85bbaf5494bc613fd32825
MD5 9402e03908ca64ca0d6f355e74707258
BLAKE2b-256 239819175f08b61e91c7d9d41de05b84f3843e724ded4135502d412165b4143c

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7.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.9.7-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 11515299b8eb3816f0b69ced7cd36aa8ccfb7aa903ab8d4a0a44228109dc06b6
MD5 19051804f64c3d84772a9e7b7fe29571
BLAKE2b-256 9e146ef4484aee9885b5d40d7d22085550b426e0508cf3b8c1864ba4052506c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 df4abb71add697c4942757505142d0da1fd5db29924f480e942fe0ee97f6dab1
MD5 0e93f4e25e9f91aa2228ccf1e7b603f3
BLAKE2b-256 a5d44101b3633f75c587ab425ab6f632f599eb122636372019b3633bfaa32074

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8f5b17b17ebdb42055ce4a49959afe13a16047af4b28eef10ffc38ced88a8c66
MD5 6a9adcba5b11dfe503cb66e2a7853aff
BLAKE2b-256 8b8e0a97042b9d7fd052b40d273f90051ee60b47a1c6cc3db81e528f9a117e74

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcc0b45b15d969528205731762fde7003ffb1ef934f82e930683612caff65445
MD5 c966449ee99565e4da48d1673d87c9a2
BLAKE2b-256 1c05e928dde4935dd2ee2a516e1a644b226ec3c57ccac41f2dc589dd85b79aa3

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 372743a8b4c1113ecbc653fe35608d1c54c4711fbbb8a0ee325661535994926d
MD5 31145501849b925c0bd54bb44bb024f9
BLAKE2b-256 7f17bf86c26415ec4cc4c735f3c6d84159f6337fc9d3eff179f2c2dcd0dba68d

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5378a8de19d159e0ed93c0197f50f160dc59e625f3919ee1b37b0c166a30888
MD5 d48506a073c26805dd3a7cc8a1fb0e38
BLAKE2b-256 834a451e106cfcb25e45a3078f4103c22dd42d16c8f4a6dc21b7541612519691

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 247791a5d43b6ce8dc2ef12de26aa5d4d0a9520ff1557716c89cac90eacbce2f
MD5 bc3aa872ec8666feca719caddf586428
BLAKE2b-256 d5ee3924becbce011ec7b504aff2820ba721bf013e31a0e4fcf62e1e59456549

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f4ceac572bd864dce2c4686d1d52925208c4612b70598184dc62d1e6f9cdd965
MD5 3bbd1dd415263c254870e1dd7d2ef151
BLAKE2b-256 028441231eb48561444adbe15f2c698e740d3bd0cb2a65cc5e324cca48ad57fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1a2e222f4f3274de05a74e583b7a4e3559f37e694ed46ee4169bf7fca0eb28e7
MD5 05d1489591c1d3f80539d1bd9f6e96f5
BLAKE2b-256 b37ccd7a9a1c34ecf8ec9caf35ebf76136f74b72fd88f9f2414ed6cea658a1fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e10b04d7f64c2dd07f1013bd81594390cabdca159541a5c793ec7220f9bc6a9
MD5 9dd3893f40c7155c578eb6ffcdedc3b8
BLAKE2b-256 2d4354284b50c7e6394052f88426c4721fdee697a5ae81b052c4883d99837f7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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.9.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for essence_wars-0.9.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 51ef3790a2e41849df81142b5fa93d74f2bfa0ce4cc000e5c3621768f5535132
MD5 e175460203631a9f2909f4dffad5cd25
BLAKE2b-256 f4bfe3d91d786e7db0de6d2e5a3bba29930f0aee0a9ea717eb61d5445a94a1a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for essence_wars-0.9.7-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