Skip to content

goChess

CI Lint Go Reference License: GPL v3

A UCI chess engine written in Go, built on the dragontoothmg magic-bitboard legal move generator.

Status

Early. The engine plays legal chess via a UCI loop with:

  • Move generation — delegated to dragontoothmg (verified with perft).
  • Evaluation — tapered PeSTO material + piece-square tables, bishop pair, passed pawns, mobility, king safety, tempo.
  • Search — iterative deepening with aspiration windows, principal variation search, quiescence search, a shared aged transposition table with hash-move ordering, MVV-LVA + killer-move + history move ordering, null-move pruning, late move reductions, Lazy SMP (multi-threaded search), asynchronous search with working stop and pondering, hard time limits.
  • Opening book — optional Polyglot .bin book.

Not yet implemented: Syzygy endgame tablebases, static exchange evaluation. See the roadmap.

Install

go install github.com/cjunius/goChess/cmd/gochess@latest

Or build from source:

git clone https://github.com/cjunius/goChess
cd goChess
make build            # produces ./bin/gochess

Usage

gochess                      # UCI mode — point a GUI (CuteChess, Arena) at this
gochess perft 6              # timed perft series from the start position
gochess perft 4 "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1"
gochess bench                # fixed search benchmark (nodes/sec)
gochess version

Playing a game

Add the binary as an engine in any UCI GUI, or pipe commands directly:

setoption name Hash value 128
setoption name Threads value 8
position startpos moves e2e4 e7e5
go movetime 1000

UCI options

Option Default Range Meaning
Hash 64 1–4096 Transposition-table size in MiB.
Threads 1 1–256 Lazy-SMP worker count (capped at the machine's core count at search time).
Ponder false check Let a GUI drive go ponder / ponderhit so the engine thinks on the opponent's clock.
OwnBook false check Play from the Polyglot book when the position is in it.
BookFile string Path to a Polyglot .bin book; loaded when set.

Development

make test          # go test -race ./...
make lint          # golangci-lint
make vuln          # govulncheck
make cover         # coverage report

See CONTRIBUTING.md and docs/development.md.

Project layout

cmd/gochess/       main entry point + CLI subcommands
internal/engine/   perft, evaluation, search
internal/uci/      UCI protocol loop
docs/              architecture notes and ADRs

Roadmap

  • Move generation on dragontoothmg + perft regression tests
  • Evaluate(pos) — material + piece-square tables
  • Negamax + alpha-beta + iterative deepening + time budget
  • UCI loop
  • Quiescence search + MVV-LVA move ordering
  • Transposition table (Zobrist hash from dragontoothmg) + hash-move ordering
  • Lazy SMP — multi-threaded search over the shared TT (Threads UCI option)
  • Killer moves + history heuristic
  • Null-move pruning + late move reductions
  • Aspiration windows + principal variation search
  • Tapered PeSTO evaluation + pawn/mobility/king-safety terms
  • Asynchronous search — working stop and pondering
  • Opening book (Polyglot)
  • Syzygy tablebase probing (ADR 0003)
  • Strength testing harness (SPRT via cutechess-cli)

License

GPL-3.0. dragontoothmg is also GPL-3.0.

About

Chess Engine in Golang

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages