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 or of annotated moves 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, or of annotated moves, into one typed array per fact, filled natively at nearly the rate the facts are computed.

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 of the position facts and of the move facts: 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.1

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.1
File Size Uploaded Provenance Actions
esca-0.4.1.tar.gz 314.8 kB With provenance Details for esca-0.4.1.tar.gz

Built distributions (wheels)

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

Total release size: 7.6 MB

Release files / esca-0.4.1.tar.gz

Download URL esca-0.4.1.tar.gz
Size 314.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f3ea512dc29b74a5e3b91a6b1a821a7e2a5fb47100393caf18f46fdbbeca8a5f
BLAKE2b-256 checksum
How to use checksums
6e05df3c601cdbfa1b3dd137d2ed92091f90e5f3dbb3a5a1185eb17bd5edd9d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

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

Download URL esca-0.4.1-cp312-abi3-win_amd64.whl
Size 1.3 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2c43d547cd50440761db7eea088fce437f6b320040e8feb8ec37bba8a4eb972e
BLAKE2b-256 checksum
How to use checksums
cb502c6eb149eb2554789b58b2847c88a66ea3d2ee5c236e497fe1403064ac3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

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

Download URL esca-0.4.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_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
80d8dae9d39b1345cee870f1da50749eae1d2d3f923303802d5461c0a6291a6b
BLAKE2b-256 checksum
How to use checksums
1975f6178fd3edd90c5d134b1ec1ecdb512d340f9c9a84000516512d42e7c806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

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

Download URL esca-0.4.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.5 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
7505b1bf7e391db350fa81a71125f992482d972d436ecbfd1b28e2c56807b48d
BLAKE2b-256 checksum
How to use checksums
6a6a93419c04f136e8823ab1b24f17e12010262310faee1bd1d9afd469375196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

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

Download URL esca-0.4.1-cp312-abi3-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a11a49958114c1dfe9c3b7c70e2b8a9af2a5b5d780109bf38ef41f4a0c918ce6
BLAKE2b-256 checksum
How to use checksums
ab707fa431bef82ba2b742549e4ccea7dc1b1dccf341f5c86d2e7a894026fc3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

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

Download URL esca-0.4.1-cp312-abi3-macosx_10_12_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2809281da49df381c5658fcb470df7d1f1418d5a6841e634f398ebf9adb71750
BLAKE2b-256 checksum
How to use checksums
a80665d9289695e522616fa299c185ea46522113c28bffdff7d4ed50fa4567c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

Security for esca 0.4.1

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for esca-0.4.1.tar.gz

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 Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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