This repository is
CHESS-COBOL-CODEX(folderCOBOL-chess), one of 16 COBOL systems developed from scratch by frontier coding agents in the multi-case study Coding Agents Develop COBOL Systems: Evidence from a Multi-Case Empirical Study (2026).What it is: a UCI chess engine written in COBOL, architecture-first (184-feature backlog). Oracle: phased per-feature validation and perft. Built by: Codex (
gpt-5.2) in recorded sessions: 26 substantive prompts, 5.0 active hours, 3,359 lines of COBOL, difficulty High.The code, documentation, and git history are preserved as the agent produced them (treat them as research artifacts). Study hub with all 16 systems, the analysis pipeline, session logs, and replay packs: https://github.com/acherm/agentic-cobol-study
cobochess is a small but real chess engine written in GNUCobol. It speaks UCI, enforces full chess move legality, exposes command-line perft modes, and ships with a benchmarking harness built around cutechess-cli and Stockfish.
This repository now has two documentation layers:
README.md: quick project overview, feature list, build/run workflow, and a compact architecture summary.ARCHITECTURE.md: the longer technical report covering data structures, control flow, search, evaluation, tooling, and current limitations.
- Multi-program GNUCobol engine:
COBOCHESS,SEARCH,ALPHABETA,QUIESCE,MOVEGEN,MAKEMOVE,UNMAKEMOVE,ATTACK,EVAL,FEN,TIMEUTIL, andMOVE2UCI. - Board representation: a shared 0x88 mailbox board stored in
GAME-STATE. - Move legality model: pseudo-legal generation plus legality filtering through
MAKEMOVE/UNMAKEMOVE. - Search: iterative deepening negamax with alpha-beta pruning, aspiration windows, principal variation search, quiescence search, transposition table, killer/history heuristics, null-move pruning, late-move reductions, late-move pruning, check extensions, and mate-distance pruning.
- Evaluation: material plus centralization, pawn structure, passed pawns, rook open-file bonuses, king placement, king shield, bishop pair, and tempo.
- Hashing: deterministic Zobrist tables with incremental key updates during make/unmake.
- Tooling: perft regression tests, UCI smoke tests, a Cute Chess tournament harness, and PGN-based Elo estimation scripts.
flowchart TD
A["COBOCHESS\nmain.cob"] --> B["BOARD + FEN"]
A --> C["SEARCH"]
C --> D["MOVEGEN"]
C --> E["MAKEMOVE / UNMAKEMOVE"]
E --> F["ATTACK"]
C --> G["ALPHABETA / QUIESCE"]
G --> D
G --> E
G --> H["EVAL"]
A --> I["MOVE2UCI + TIMEUTIL"]
J["Python tools\nperft / cutechess / elo"] --> A
What emerges is a compact conventional engine built with COBOL records and recursive subprograms instead of bitboards and packed move integers. The result is explicit, debuggable, and surprisingly serious.
- Full rule handling: castling, en passant, promotions, checkmate/stalemate detection, repetition detection, and the 50-move rule inside search.
- UCI support for the common engine loop:
uci,isready,ucinewgame,position startpos|fen,go depth,go movetime, and clock-drivengo. - CLI perft modes for correctness testing:
--perft-startpos <depth>--perft "<fen>" <depth>
- Root search info output in UCI format.
- Deterministic opening suites in
openings/book.pgnandopenings/book.epdfor tournament runs. - No tournament results are preserved in this repository (the Elo measurement of the study lives in the sibling Claude Code engine,
agentic-chessengine-cobol-cc).
Requirements:
cobc(GNUCobol 3.2.x works here)python3- Optional for matches:
stockfish,cutechess-cli
Build the engine:
make buildThe main binary is produced at bin/cobochess. The Makefile also runs a post-build smoke check and includes macOS-specific signing/quarantine workarounds.
Run in UCI mode:
./bin/cobochessMinimal example:
printf 'uci\nisready\nposition startpos moves e2e4 e7e5\ngo depth 4\nquit\n' | ./bin/cobochessRun correctness checks:
make perft
make uci-smokeRun a match against Stockfish:
python3 tools/elo_run.py --games 20 --sf-elo 1320Estimate Elo from the resulting PGN:
python3 tools/elo_calc.py results/match_YYYYMMDD_HHMMSS.pgn --baseline-elo 1320| Path | Role |
|---|---|
src/ |
Engine code: entry point, board state, move generation, make/unmake, attack detection, evaluation, search, timing, UCI formatting |
copybooks/ |
Shared COBOL data layouts and constants (GAME-STATE, move records, search state, hash tables) |
tests/ |
Perft regression cases |
tools/ |
Python/shell helpers for smoke tests, engine checks, tournaments, and Elo estimation |
openings/ |
Deterministic opening suites used by the match harness |
cutechess/ |
Vendored third-party Cute Chess source/build tree used for engine-vs-engine evaluation |
bin/ |
Built binaries; bin/cobochess is the authoritative engine target |
- The engine uses COBOL records as explicit chess structs instead of squeezing state into packed integers.
search.cobcontains the heart of the engine: the root iterative deepener plus recursiveALPHABETAandQUIESCE.makemove.cobis the state-transition hub: it updates board state, undo information, castling/en passant, clocks, king squares, and incremental hash keys, then rejects illegal king-in-check positions.- The evaluation is no longer material-only; it includes several classical handcrafted terms.
The longer report is here: ARCHITECTURE.md.
- The engine advertises a
HashUCI option, butsetoptionhandling is not implemented yet, so table size is effectively fixed in code. stopis parsed, but search is synchronous; in practice the engine stops on its own time controls rather than from an asynchronous interrupt.- No integrated opening book lookup, no tablebases, no multi-threading, and no incremental evaluation.
- UCI
infooutput reports the current best move as a one-move PV rather than reconstructing a full principal variation line.
Those gaps are documented in more detail in ARCHITECTURE.md, together with obvious next engineering steps.