gambit

module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: MIT

README

gambit

CI codecov Quality Gate Status Go 1.26 MIT License

Two chess agents play each other, every move logged to the terminal in algebraic notation — headless by default, or in an optional Ebiten window. Built as a testbed for experimenting with search strategies — see docs/demos.md.

Install

Homebrew
brew install danielriddell21/tap/gambit         # CLI (all platforms)
brew install --cask danielriddell21/tap/gambit  # native macOS GUI window

Layout

  • cmd/gambit — entry point.
  • pkg/chess — reusable chess engine (board, moves, legality, FEN, results). The only public package.
  • internal/agent — pluggable Agent interface + the random and minimax strategies.
  • internal/game — turn orchestration, draw detection, SAN.
  • internal/ui — Ebiten rendering.

Usage

Needs Go 1.26.3, just, and (for the GUI) Ebiten's system deps.

just run                       # terminal: minimax (white) vs random (black)
just gui                       # Ebiten window (opt-in, -tags ebiten)
just test                      # tests        just perft   # move-gen correctness
just lint                      # golangci-lint just demos   # regenerate demo GIFs

Flags: -white, -black, -depth, -seed, -fen, -delay.

Linux: OpenGL/X11 libraries

The window needs OpenGL/X11. On Debian/Ubuntu:

sudo apt install libgl1-mesa-dev libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev

Adding a strategy

Implement agent.Agent and agent.Register it in an init — the game loop and GUI need no changes. Board.MakeMove/UnmakeMove (for alpha-beta) and Board.ApplyMove (clone, for keeping many positions alive) are both available, and the headless build batches games with no display.

Directories

Path Synopsis
cmd
gambit command
Command gambit runs a chess game between two agents and logs each move to the terminal.
Command gambit runs a chess game between two agents and logs each move to the terminal.
internal
agent
Package agent defines the pluggable AI-player interface and a registry of strategies.
Package agent defines the pluggable AI-player interface and a registry of strategies.
agent/eval
Package eval provides static evaluation functions for chess positions.
Package eval provides static evaluation functions for chess positions.
assets
Package assets embeds binary assets (currently the font used to render chess pieces) so they can be shared by the GUI and the demo generator without a separate copy.
Package assets embeds binary assets (currently the font used to render chess pieces) so they can be shared by the GUI and the demo generator without a separate copy.
game
Package game orchestrates a chess game between two agents: it alternates turns, validates and applies moves, tracks game-history draw conditions (threefold repetition and the fifty-move rule), and emits a move event per ply.
Package game orchestrates a chess game between two agents: it alternates turns, validates and applies moves, tracks game-history draw conditions (threefold repetition and the fifty-move rule), and emits a move event per ply.
log
Package log provides terminal logging of game progress, formatting each move in SAN for human readers.
Package log provides terminal logging of game progress, formatting each move in SAN for human readers.
pkg
chess
Package chess is a self-contained chess engine: board state, pieces, move generation, legality checking, FEN parsing, make/unmake, and game-result detection.
Package chess is a self-contained chess engine: board state, pieces, move generation, legality checking, FEN parsing, make/unmake, and game-result detection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL