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

Test Lab 🧪

Built-in QA test harness for verifying game mechanics. Each scenario pre-loads the right deck, bot, and seed — one click to reproduce any mechanic interaction.

Test Lab

Scenarios are grouped by mechanic (Ambush, Flanking, Level-Up, Overload, Prepare, Ritual) with both Player-side and Opponent-side variants, so you can verify a mechanic from either perspective. Adding a new scenario is a single .toml file drop — no recompile needed.

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 ~17,000/sec
Greedy bot games ~1,200/sec
MCTS (100 sims) ~27 ms/move
MCTS parallel (8 trees) ~13 ms/move
Alpha-Beta depth 6 ~1.05 ms/move
Engine state clone ~417 ns
State tensor encode ~168 ns
Greedy evaluate ~9.0 ns
Zobrist hash ~11.1 ns
Apply action (attack) ~188 ns
MCTS parallel speedup (8×) ~4.3× (54% efficiency)

Hardware: AMD Ryzen AI 7-350, 32 GB RAM, WSL2 (Ubuntu on Windows 11). Timing figures are hardware-dependent — run cargo bench -p cardgame to measure on your machine. The parallel speedup ratio (4.3×) and balance win-rate metrics are hardware-independent.

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.12.0.tar.gz (749.4 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.12.0-cp313-cp313-win_amd64.whl (961.3 kB view details)

Uploaded CPython 3.13Windows x86-64

essence_wars-0.12.0-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.12.0-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.12.0-cp313-cp313-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

essence_wars-0.12.0-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.12.0-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.12.0-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.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

essence_wars-0.12.0-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.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: essence_wars-0.12.0.tar.gz
  • Upload date:
  • Size: 749.4 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.12.0.tar.gz
Algorithm Hash digest
SHA256 4e159cd3d1e329caab4af59b7bce5291fba7250bdb2d7ffc5481c7751887b884
MD5 5421d9c05824600235b16423bb9715a1
BLAKE2b-256 8ebc41d2e3259bbe7cf689de0131a8073823adcc7068f752312884b074c6ea14

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b7a60dda3c8f74598ffe76743cbd5b0a02f92cc8d7d4c9068876ecd263cc4fd5
MD5 b51eef3f521216104e394c39bdcce12c
BLAKE2b-256 5b19f05619ba5a04e74d384b07936800e386aff6367eadec4b88d2b3927a820d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ecab4d89fceb4ca27a93e56427bed3935b2700fe99fdfedcbbc935e5d3d8435
MD5 0f5f7732945313626a62808c3780a2f8
BLAKE2b-256 8ee7bf448414f2f54415deb9cd3e458e0ed4d2d1d4099e35268da2541429eab0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e8f189b285b2e0caa93f4e4ec76faf35cb8e62bd3c3e84d9fdb4723dc6e82343
MD5 5f5f473239628e79f15893423b1013cd
BLAKE2b-256 39950ea1725eb730e173138d326fb3de423590d859631b43488e99044c3cb6d8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f59d79c0fd3c1a95a532953812abe0cf6e2424c4bf3a47bd0fd21cc7a19f1b8
MD5 1395c38a74c4792c6757517bbb0f0770
BLAKE2b-256 04802422fc0e60ac9b8471ba88dea611b78170a22b041dd8609dba154c22d1dd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 616102f40e98f59cba67159a76e7079f36089951d7df7b66320c65c586cf1bd5
MD5 3bb75beda9fd37e84792e20f8cd39096
BLAKE2b-256 8b7a7234a3b2f556bd9887284455aeec30bb5827f9570c5bc3ff08eb653303cc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 31fc309d1f7dc82675cd9a77bff9b0058784a9a85f411d8cf3014e72acaa642d
MD5 78948dd39b757d7694df8f32dc167aad
BLAKE2b-256 cf57d778ef2e4360865c263f1962322b782b96f988a781f1d616a89cf2c84e4d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2e8372921e8c667e3eeb9d2dbec8d5f95dcc21c7aaf9a19a69608b9e1842ab50
MD5 02805d83f2bffe66d46cc8433c7f3200
BLAKE2b-256 d7894010b5e20f4c6ea0ec36acfbc73b739b92a4b7aeee254eb9c9ebe339a510

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 979c7366524bcdb15f7cf36149bade818272c8525db7c3312dfa9d77a5de384b
MD5 60a2a0a727f15f59c324a02d5b976260
BLAKE2b-256 a10a4a6c4e2ef773b7efbdf050b6a21fde9b7cefa6451da0bad11f26f29ec2d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f3ef1de5dff9ca92a0d90a385a5b39537940535be245654587513657afdcf68d
MD5 ab9e7e124002654d5c56b95fe9f48412
BLAKE2b-256 c3c123baaccab2497899a0c08b4b51fdac6193fd8925c4aef88cd3840bc85223

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea0f7ca4ee30aca90a4254eba936428c45ef7f9d635a91f34dd64030f9a591ba
MD5 d811838176dfca63f0acf0b16c2f3e53
BLAKE2b-256 d2293f2a8449748e784df9cd0f56ee1327bda6f236a101c9c3f071cf39954d10

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0cbd02a81fdd79aaef214681c298fecd669e6bcac6c1d881498aecbbcc932149
MD5 86cbc2bd27a44f6266321cb3c67424cd
BLAKE2b-256 3f30e65dff8ee408d13b0da8e52de380f0f8ae24136340a44a1a5b90e4f54c3e

See more details on using hashes here.

Provenance

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