Skip to content

About

cobochess — A UCI chess engine written in COBOL (GnuCOBOL), built by Codex (GPT-5.2).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🧪 Research artifact of the coding-agents COBOL study

This repository is CHESS-COBOL-CODEX (folder COBOL-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

COBOL Chess Engine (cobochess)

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.

Architecture at a glance

  • Multi-program GNUCobol engine: COBOCHESS, SEARCH, ALPHABETA, QUIESCE, MOVEGEN, MAKEMOVE, UNMAKEMOVE, ATTACK, EVAL, FEN, TIMEUTIL, and MOVE2UCI.
  • 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
Loading

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.

Features

  • 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-driven go.
  • 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.pgn and openings/book.epd for 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).

Quickstart

Requirements:

  • cobc (GNUCobol 3.2.x works here)
  • python3
  • Optional for matches: stockfish, cutechess-cli

Build the engine:

make build

The 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/cobochess

Minimal example:

printf 'uci\nisready\nposition startpos moves e2e4 e7e5\ngo depth 4\nquit\n' | ./bin/cobochess

Run correctness checks:

make perft
make uci-smoke

Run a match against Stockfish:

python3 tools/elo_run.py --games 20 --sf-elo 1320

Estimate Elo from the resulting PGN:

python3 tools/elo_calc.py results/match_YYYYMMDD_HHMMSS.pgn --baseline-elo 1320

Repository map

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

What is technically interesting here

  • The engine uses COBOL records as explicit chess structs instead of squeezing state into packed integers.
  • search.cob contains the heart of the engine: the root iterative deepener plus recursive ALPHABETA and QUIESCE.
  • makemove.cob is 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.

Current limits

  • The engine advertises a Hash UCI option, but setoption handling is not implemented yet, so table size is effectively fixed in code.
  • stop is 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 info output 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.

About

cobochess — A UCI chess engine written in COBOL (GnuCOBOL), built by Codex (GPT-5.2).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages