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

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.5.tar.gz (704.6 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.5-cp313-cp313-win_amd64.whl (927.8 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

essence_wars-0.9.5-cp313-cp313-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

essence_wars-0.9.5-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.5-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.5-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.5-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.5-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.5-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.5.tar.gz.

File metadata

  • Download URL: essence_wars-0.9.5.tar.gz
  • Upload date:
  • Size: 704.6 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.5.tar.gz
Algorithm Hash digest
SHA256 f3979e1cfda4c12cac7a8f2d82b2d9354b54932d419fcf96966d0af66972ef00
MD5 b7f2b6a687370c3f27d237bf0b2c9106
BLAKE2b-256 a45b7a21cff57625a06e5ba0266eb7e797e23237ecb06b7795dd55e40b8228b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3fd3208510c2d567391ba686beb60669c4e258809bad12ffaab73e24793bec0b
MD5 5afed82b74d4b60ca407606ecc17eafd
BLAKE2b-256 84f2d2954adfbf63279e466ab901553eb391fc24418f22110e5aa5ab6b9f785c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 365222168f1d135b8d86a30dde723250e579cadc3ae7ed1d3877a9c08e935326
MD5 948072868333c60ccf9afdf89e0b7064
BLAKE2b-256 2ec39bb918157b2112da17e4c0db78b87c2570f036d2001540cf36e60cccb3f7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b60e3bcb270453bcc14231af5e052fb0cabc9a428b61f4e76b050bef66d8e6aa
MD5 f97cc6910cd972066b27532e773b3993
BLAKE2b-256 b14fb9b8739b1464fde43b55a8ee49b55c41fe8c578fcad032dfb8a5210040bc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 589acff4817c079d969e9962c9209fc3f3eceb9503a572350ec2e36bbe4c183a
MD5 2b5d194c97c307f80c02a62891f62223
BLAKE2b-256 0769ea88bf4e44cf7b7a0a26f5b3e7ab2c92cc4201600d3cf5d3bb2b38b43133

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 90703cf75f8c6f42e556c0d9d861bdf6a27ae0335f5e02c4015b7c519d0d2053
MD5 4d59c6376bfd6b725fb44055716f4d6e
BLAKE2b-256 1d5f372117ea3acc5e516aad4b3545a85f14fcdb264ff70762ae77fbdac46681

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1fe3d922d30ecc37e7e12cc0ccb78840d0db5294a1cedb659b97a85f2755413
MD5 2ae83fc3697528cd435915f03283f28b
BLAKE2b-256 5a051dfde45d64dd999c2e5d87898bd57fb784a265e25a613191b0574b509d83

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6546d31d79846ebb7a1deb3424ae5d2bbe8f3a85dfb3990b7c3ec155a3f05b7b
MD5 128f4ec6b9e7b780fb2f0202e86ce1b9
BLAKE2b-256 eb7f27eb10e15e9155192146826e8095d342db101ad04f14fb347cc63f5fceb7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 41484e5c3533739a3ee97e7131688892d5d649656441d56513dca2d96f420fe0
MD5 27b9b67e14111a2fbe00a93fb977d01e
BLAKE2b-256 bf3b71414720bdd284d1017e78e5708334d7a5fc56f8e3698891071d529d6755

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 878c1474f53df34618cc1e798b889e32e6aa9feadab64177cf519760f85f57ff
MD5 24cce4bf860f54d0b7f6642417495f80
BLAKE2b-256 12998f7b61d3abc450c746e8f1a98a9625296f4e510174b51e3b3973502f302c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 464e0a15fd4c75a51bc115b219b9c10fdf3434a9ab5a0824070228c83ff3da5b
MD5 52145c32053b779695b31afe2a71fb6e
BLAKE2b-256 7b5018c7e81c8391005dfd9fe80f7a93c7729a499e7ca3af471cada5d332e168

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for essence_wars-0.9.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2fc15acc38f8b043ed149fbf4178ab14cf52540bc09bdb9f19d3125fb6f094b8
MD5 33246e57655252297a9bf536fbf36dc6
BLAKE2b-256 ebf492bd7df559c614b79eaaaf8fedbd9c854aa44b7c7b27ace1677087e6d2d3

See more details on using hashes here.

Provenance

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