Skip to main content

esca

crates.io docs.rs PyPI Python CI MIT

Esca is the anglerfish's lure — the light that shows what is really on the board.

Rust/Python MIT chess library: rules, facts, explanations, PGN, opening books and names, UCI client, and an MCP server over it; one API, Chess960 throughout.

Position is placement and state and nothing else. Rules live in Variant implementations — Classic and Chess960 — so a position answers a rules question by taking the variant that defines it, and a new variant is a new implementation and nothing else. A Game pairs a variant with the moves played, which is what repetition and claimable draws need. Facts answers what is true about one position — 221 named facts in 14 groups — and annotated_moves() answers what each of its legal moves does, with 27 more. Every fact is typed, named after what a player would call it, and told about White and Black by name.

Rust

[dependencies]
esca = "0.4"
use esca::{Colour, Game, classic};

let mut game = Game::new(classic());   // Chess960 rules: `esca::chess960()`
game.play_san("e4").unwrap();
game.play_uci("e7e5").unwrap();
println!("{}", game.position().fen());

let facts = game.facts();
println!("{}", facts.tactics.legal_move_count.white);
println!("{:?}", facts.pawns.passed.of(Colour::Black).files());
println!("{}", facts.summary());

Cargo features, none on by default: lichess (streaming reader for the Lichess evaluation dump), pgn (reading and writing games as PGN), polyglot (opening books), openings (the bundled ECO catalogue), serde (the one JSON form of the facts, and the JSON Schema for it), tensors (a run of positions as one typed array per fact) and python (the PyO3 module the wheel is built from). Position::polyglot_key needs no feature.

Python

pip install esca
import esca

game = esca.Game()  # Chess960 rules: esca.Game(variant=esca.CHESS960)
game.play_san("e4")
game.play("e7e5")
print(game.position.fen)

facts = game.facts()
print(facts.tactics.legal_move_count.white)
print(list(facts.pawns.passed.black.files))
print(facts.to_dict()["material"])  # every group in the one JSON form

Wheels are abi3 for Python 3.12 and up. pip install esca[tensors] adds NumPy and esca.tensors, which turns a run of positions into one typed array per fact.

Examples

Three short programs a side, reading the same examples/games.pgn, in examples/ and python/examples/:

  • pgn_report / read_games.py — per game of a PGN file: opening, final position, ending, passers.
  • why_illegal / legal_moves.py — every legal move and what it does, then why one other is not.
  • engine_game / engine_game.py — a UCI engine against itself, its ending as English, JSON and arrays. Takes the engine's path; without one it says so and stops.

What it covers

  • Classic chess and Chess960, behind one Variant trait.
  • FEN and EPD, reading KQkq and the AHah of X-FEN and Shredder-FEN alike, and writing KQkq whenever the rook files allow it.
  • Legal move generation into a MoveList that never allocates.
  • UCI move text in either castling spelling, and SAN with the disambiguation it needs.
  • Checkmate, stalemate, insufficient material, the fifty- and seventy-five-move rules, and threefold and fivefold repetition.
  • Facts: fourteen groups of cheap facts about one position — the board itself, game state, history, material, pawns, pieces, king, mobility, attacks, exchanges, threats, one-ply tactics, endgame and the attack maps side by side — and MoveFacts for every legal move, from annotated_moves(). Every value that differs between the two sides is a ByColour, read as .white, .black or .of(colour).
  • A catalogue of those facts as data — name, type, dtype, shape and meaning — which docs/features.md, docs/facts.schema.json, the Python type stubs and the tensor layout are all generated from, and which the MCP server serves.
  • One JSON form for the facts, written by Rust's serde::Serialize and by Python's to_dict(), byte for byte the same and described by docs/facts.schema.json.
  • A typed tensor export: one array per fact, batch first, each keeping the width and sign it was declared with — nothing scaled, normalised or cast to a float — expanded or bit-packed, and written as safetensors.
  • Polyglot opening books: the format's own key on every Position, books read, drawn from and built, and an ECO code and name for some 3,800 named positions.
  • Named endings with theory verdicts and technique names, and a one-line English describe() beside every value the explanations layer answers with.

MCP server

mcp/ is a second distribution from this repository: chess-esca-mcp, an MCP server that hands esca's answers to an LLM as JSON — the whole state of a position, whether a move is legal and every reason it is not, the named facts, the ECO name, opening-book moves, and PGN read and written. It carries no engine and does no search. It runs as uvx chess-esca-mcp, is versioned with the library and pins the matching esca, and is documented in mcp/README.md.

Documentation

  • AnglerfishChess/anglerfish — the chess engine that plays from a learned evaluation, and the Python trainer that produces it. Both are built on esca; the trainer turns its facts into the rows a net eats.
  • AnglerfishChess/uci-test-suite — a conformance suite that checks a program is a valid UCI engine, whatever its strength. It talks to the engine under test through esca's UCI client.
  • AnglerfishChess/chess-uci-mcp — an MCP server that drives UCI engines from an LLM, so an esca position can be handed to Stockfish for a number and a line to go with the facts esca reads off it.
  • AnglerfishChess/plugins — the agent-plugin marketplace, where chess-esca-mcp ships with a skill that teaches an agent which of its tools answers which question.

License

MIT — see LICENSE.

Acknowledgements

  • cozy-chess (MIT) — the move generator esca stands on.
  • Lichess — the evaluation dump the lichess reader streams, the game database, and lichess-org/chess-openings, whose opening names the openings feature bundles (CC0 1.0 Universal Public Domain Dedication).
  • The Polyglot opening-book format and its key scheme, by Fabien Letouzey; the key constants are those published in polyglot-book-rs (MIT OR Apache-2.0).
  • Stockfish and Leela Chess Zero, the engines the UCI client is tested against.

Metadata

Release files for esca 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for esca 0.4.0
File Size Uploaded
esca-0.4.0.tar.gz 311.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for esca 0.4.0
File
esca-0.4.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
esca-0.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details
esca-0.4.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details
esca-0.4.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details
esca-0.4.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details

Total release size: 7.5 MB

Release files / esca-0.4.0.tar.gz

Download URL esca-0.4.0.tar.gz
Size 311.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f4119286d11d92116a4f033df483e030f36b6200c497358fc9dc0fb49d5f15fe
BLAKE2b-256 checksum
How to use checksums
486c5f045f424e49acaa1562b8b263e8a69186615957fb0ca566bdfb62092516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / esca-0.4.0-cp312-abi3-win_amd64.whl

Download URL esca-0.4.0-cp312-abi3-win_amd64.whl
Size 1.4 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
447bb19bf66915d34cdc920b6fcfa5b9a5c9f49f763d5687f904dfa21a407e1c
BLAKE2b-256 checksum
How to use checksums
65915a2834ebb81a2b7f882a302d0b42dad8ee40b4b5da89e4b555bfb3b3a90c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / esca-0.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL esca-0.4.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
fe25a5fce35dd4eb34c458794c075d146ea122d83d0f412d2176847dc21e7656
BLAKE2b-256 checksum
How to use checksums
1b18ca35b422a8b4094c6d47f1b253f5f2ebc88f5cf3fca151bc3af0c5bb1d6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / esca-0.4.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL esca-0.4.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.5 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
31f3cab971721c3d00c7b29c79ff6d15f2e6377fafc6936b8315f541b03f4c0f
BLAKE2b-256 checksum
How to use checksums
3dcb63dc545471eec990afa5430868f1fb9dea5983518ba421a30629bf52ecd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / esca-0.4.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL esca-0.4.0-cp312-abi3-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e2b5a6c1ea89c7809aab9bb1a47d2107506f87fac1f2789fc65966feb3aea85c
BLAKE2b-256 checksum
How to use checksums
26847a2481e567dda017a43d3551c98daad65ef5dd07711de49b398943105a7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / esca-0.4.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL esca-0.4.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 1.4 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
577a9f69c0ef8b7677379056f9190221f58da74877eb0fa0b481c3c5fae30fb4
BLAKE2b-256 checksum
How to use checksums
e32066383474536b3c584bd877c8d3c6be6c13f162f5d6061165cb466be8b75a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

6 release files

0.3.0

6 release files

0.2.1

6 release files

0.2.0

6 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page