Skip to content

About

Team-Olympiad benchmark for LLM-generated chess engines (C++20, Linux)

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

ChessLLMBench

A team-Olympiad benchmark for LLM-generated chess engines.

ChessLLMBench is a Linux C++20 benchmark for teams of ten independently generated chess bots. The framework supplies chess rules, clocks, compilation, isolated game processes, tournament scheduling, team/individual results, and verification. Each bot contributes one board-player program; bots do not share state or coordinate during a game.

Build and run

Requirements: Linux x86-64, CMake 3.20+, and a C++20 compiler (g++ by default).

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
ctest --test-dir build --output-on-failure

./build/chessbench validate-bot bots/<team>/board_01.cpp
./build/chessbench compile-bot bots/<team>/board_01.cpp
./build/chessbench compile-bots bots/
./build/chessbench tournament --config configs/official.cfg

Place each team in its own immediate subdirectory of bots/, with exactly ten .cpp files directly in that directory:

bots/
  model_a/
    board_01.cpp
    ...
    board_10.cpp
  model_b/
    board_01.cpp
    ...
    board_10.cpp

Root-level .cpp files are legacy individual submissions and are ignored by team tournaments. A team folder with fewer/more than ten direct .cpp files is rejected. generate.ipynb makes ten separate model requests, validates and compiles the staged roster, and promotes it to bots/<team>/ only if all ten submissions pass.

For a batch across the configured 11-model roster, set OPENAI_API_KEY and OPENAI_BASE_URL in the environment, then run python3 scripts/generate_teams.py. OPENAI_BASE_URL is the API base URL (for example, https://api.openai.com/v1 or your provider's OpenAI-compatible endpoint); no tenant-specific endpoint or credential is embedded in this repository. The script uses the current Prompt.md, the 4,096-token validator, makes ten independent requests per model, and promotes only complete, validated, compiled teams. Set CHESSLLM_MODELS to a comma-separated model list to override the configured roster. Attempt prompts, responses, diagnostics, and manifests are saved under generation_runs/; that private generation archive is deliberately excluded from public releases. Rerunning reuses complete teams and validated staged sources. The script never writes the API key to disk.

The tournament prints the run directory. Resume with:

RUN_DIR=/absolute/path/to/the/printed/run-directory
./build/chessbench tournament --config configs/official.cfg --resume "$RUN_DIR"
./build/chessbench verify "$RUN_DIR"

Other commands include perft, play, leaderboard, tournaments, recent, tournament-info, tournament-stats, bot-stats, team-stats, compare, team-compare, opening-stats, timecontrol-stats, forfeits, games, game, bot-history, and stats. Use ./build/chessbench help for exact syntax. Analytics commands accept --json; history commands accept --results <directory>.

Bot submission and limits

Each generated .cpp file implements this function, includes the public header, and does not define main():

chessbench::Move next_move(
    const chessbench::Position& position,
    const chessbench::BotContext& context
);

The public API exposes board state, legal move generation, make/unmake, move history, repetition information, clocks, and a deterministic game seed. It does not provide an evaluator, search, opening recommendations, an engine, or tablebases. See Bot_Docs.md and bot_sdk/bot_template.cpp.

The official V1 source budget is 4,096 counted C++ tokens per submitted file. The validator counts the actual source file before compilation; 4,096 is accepted and 4,097 is rejected as BOT_TOKEN_LIMIT with actual and maximum counts. The deterministic C++ lexer adapts Sebastian Lague's Chess-Challenge token-counting convention: whitespace and comments are free; commas, semicolons, closing braces/brackets/parentheses, and public:/private:/protected: labels are free; an opening brace/bracket/parenthesis counts once; ordinary identifiers, numbers, and punctuators count once; string literals count by their raw source-text length. It is a source-token budget, not an LLM tokenizer. The runner, framework/SDK headers, and binary are not included. Override with bot_token_limit or --token-limit for non-official experiments; official config fixes 4,096.

Official runtime limits are 256 MiB and one thread per bot. Every game starts fresh bot processes; each process persists for its side's moves during that game. Official games use wall-clock timing, strict sandbox mode, one worker by default, and 10+0.1 (10,000 ms plus 100 ms after each accepted legal move). Run official tournaments as an unprivileged user. Sandboxing uses Linux process, resource, and syscall controls; it reduces risk but is not a claim of perfect isolation.

Team match format

The fixed pool has 50 legal starting positions: opening_00 is the normal chess start and opening_01–opening_49 are the predefined suite in openings/official_v1.fen. The engine validates each position when the pool loads. Pool version and canonical SHA-256 are recorded in the manifest and every game result.

For each unordered team pair, opening_00 is mandatory and four distinct openings are deterministically sampled without replacement from the other 49. The selection is based on tournament seed, both immutable team identities (roster source hashes), and pool version/hash. The exact five opening IDs are persisted before the matchup and reused on resume.

Each selected opening is one ten-board team match: every player from both rosters plays exactly once, with one team White and the other Black on each board. Board/color parity gives each team five White games per opening. This is 5 openings × 10 boards = exactly 50 games per team pair, all at 10+0.1; each team receives 25 White and 25 Black games over the matchup.

Team matchups are interleaved in deterministic Olympiad-style round-robin order. A round-robin cycle schedules every unordered team pair once before any pair starts its next selected opening. The five selected openings form five such cycles, so a team pair's five ten-board matches are spread throughout the event instead of being played consecutively. With an odd number of teams, the cycle has one logical round per team and one team has a bye in each round; with an even number, it has one fewer round and no byes. Team pairings and within-round order are derived from the stable team-identity ordering; the exact schedule is persisted and resume follows it unchanged. Each ten-board team match is still run sequentially (workers remain fixed at one for adaptive lineups).

Within a ten-board match, after each completed board the engine recalculates the order among the still-unplayed players from canonical results across earlier tournament games and earlier boards in the current match; it persists the next board before starting it. Each roster member remains limited to one game per opening, so no player can be repeated within a ten-board match. The selection is deterministic, with score/win/name tie ordering, and can be replayed on resume. New runs record team_schedule_version=2; legacy version-1 schedules remain verifiable and resumable without changing their original order.

Team standings use this explicit tiebreak order:

  1. Match points: each ten-board opening round is worth 2 points for a team match win, 1 each for a drawn team match, and 0 for a loss.
  2. Direct match points earned against teams tied on match points.
  3. Total board points (individual game scoring: win 1, draw 0.5, loss 0).
  4. Sonneborn–Berger: each completed team-match result factor (1, 0.5, or 0) multiplied by that opponent's final match points, summed over opening rounds.
  5. Board wins.

Teams equal on every listed tiebreak share the same competition rank; name ordering is only for stable display. leaderboard.json includes team standings and all individual player standings; leaderboard.csv is the team table, player_leaderboard.csv is the individual table, and separate pairwise matrices are emitted for teams and players.

Performance scores

Performance Scores supplement, but never replace, the displayed Games/Wins/Draws/Losses/Points/Score% or official rank.

Each individual player's metric uses their tournament record and individual rank. The team metric aggregates all ten players' board results and uses the official team rank/tiebreaks. For either entity:

R = points / games
P = (N - rank) / (N - 1), or 1 when N = 1
OpponentRankPercentile = (N - opponent_rank) / (N - 1), or 1 when N = 1
OpponentStrength = 0.70 * opponent score rate + 0.30 * OpponentRankPercentile
Weight = 0.5 + 0.5 * OpponentStrength
H2H = points against opponent / games against opponent
Q = sum(H2H * Weight) / sum(Weight)
Performance Score = 100 * R * (0.60 + 0.20 * Q + 0.20 * P)

Values are clamped for safety and displayed to two decimals. A score of 100.00 means a perfect tournament: all games won, perfect weighted head-to-head results, and rank 1. It is not a rescaled “best in this field” score; a tournament winner that drops any game remains below 100. Scores are recalculated from canonical game results and checked by verify.

Results, history, and reproducibility

Each run stores a manifest, persisted pair-opening selections, a schedule, canonical per-game JSON, PGNs, team/player leaderboards, pairwise matrices, and live completion counts. Completed game data is atomically written for safe resume. The verifier checks game inventory, deterministic lineups, opening pool and selections, hashes, results/PGN consistency, and recomputed team/player standings and scores. Live game rows show the actual White and Black player identities; the displayed board slot is the pairing order for that round and can differ from either player's board_XX roster identity as adaptive lineups change.

Tournament IDs, team source identities, opening selections, game IDs, and game seeds are deterministic for the same configuration and roster. Lineups are deterministic from completed prior-game records and the fixed interleaved match scheduling order. Actual moves are reproducible only if each bot is deterministic and compiler/runtime conditions are held constant. Run with the same binaries, compiler, seed, opening pool, configuration, and one worker for the clearest reproduction.

Public V1 release

The official v1.0.0 release is maintained by Jethi Labs. This repository contains the framework; the ten-player model rosters and the completed official 2,750-game result set are attached as public Git submodules. Clone with git clone --recurse-submodules https://github.com/Jethi-Labs/ChessLLMBench.git to fetch them. The result repository includes the exact compiled artifacts needed for verify; run that command from this repository's root. Raw model API request/response traces are not published. Generated bot submissions and the tournament dataset have no separate reuse license unless their respective repository states otherwise; the MIT license here applies to the ChessLLMBench framework code.

About

Team-Olympiad benchmark for LLM-generated chess engines (C++20, Linux)

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages