Rebuild engine on dragontoothmg and add enterprise repo scaffold - #1
Merged
Merged
Conversation
Replace the notnil/chess prototype (random mover + perft) with a real
engine built on github.com/dylhunn/dragontoothmg, a magic-bitboard legal
move generator, and lay out the repository in the standard Go +
enterprise-GitHub structure.
Engine (internal/, cmd/):
- internal/engine: perft wrappers with published-count regression tests
(startpos to depth 6, Kiwipete to depth 4); static evaluation
(material + Michniewski piece-square tables + bishop pair, side-to-move
relative); iterative-deepening negamax + alpha-beta with quiescence
search, MVV-LVA ordering, mate-distance scoring, and a hard time budget.
- internal/uci: UCI loop (uci, isready, ucinewgame, position, go, stop,
quit) supporting go depth/movetime/wtime/btime and "mate N" scoring.
- cmd/gochess: CLI with uci (default), perft, bench, version subcommands;
version/commit/date injected via -ldflags.
- Guard against an illegal-position crash in dragontoothmg: it can
generate a king-capturing move when the side not to move is in check,
then panic on the empty king bitboard. Relevant since FEN/UCI input is
untrusted.
Repository scaffold:
- Docs: rewritten README, CONTRIBUTING, SECURITY, SUPPORT, MAINTAINERS,
CODE_OF_CONDUCT (Contributor Covenant 2.1), CHANGELOG (Keep a
Changelog), docs/architecture.md, docs/adr/{0001,0002}.
- .github: CODEOWNERS, dependabot (gomod + actions + docker), PR template,
issue-form templates, workflows for CI (OS x Go matrix, race, coverage,
tidy check, govulncheck), lint (golangci-lint + gofumpt), CodeQL, and
release (GoReleaser + SBOM).
- Tooling: Makefile, .golangci.yml, .goreleaser.yaml, multi-stage
Dockerfile to distroless, .dockerignore, .editorconfig, .gitattributes,
updated .gitignore.
Module path is github.com/cjunius/goChess. License stays GPL-3.0, which
matches dragontoothmg.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
cjunius
force-pushed
the
feat/engine-on-dragontoothmg-and-repo-scaffold
branch
from
August 30, 2026 20:14
ee550f2 to
5106f79
Compare
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Two things in one change:
notnil/chessprototype with a real engine built ondylhunn/dragontoothmg, amagic-bitboard legal move generator.
notnil/chessis convenient butallocation-heavy and far too slow for a search that visits millions of
nodes/sec. Writing our own bitboard generator is a worthwhile project but
not the point of this one (search + evaluation), so we build on a
dedicated library. Rationale recorded in
docs/adr/0002.cmd/+internal/, plus the full set of community/health files, CI, andrelease tooling.
Closes nothing (no tracking issue).
What changed
Engine
internal/engineperft.go— thin wrappers overdragontoothmg.Perft+ timed series +divide. Regression tests against published node counts: start position to
depth 6 (119,060,324) and Kiwipete to depth 4, gated behind
-short.eval.go—Evaluate(*Board) int: material + Michniewski piece-squaretables + bishop-pair bonus, returned relative to the side to move.
search.go— iterative-deepening negamax + alpha-beta, quiescence search(captures/promotions), MVV-LVA move ordering, mate-distance-aware scoring,
hard wall-clock budget (checked every 2048 nodes; returns the last
completed depth).
internal/uci— line-based UCI loop:uci,isready,ucinewgame,position(startpos/fen+moves),go(depth,movetime,wtime/btime),stop,d,quit. Emitsinfo+bestmove, rendersscore mate N.cmd/gochess— CLI:uci(default),perft <depth> [fen],bench,version.version/commit/dateinjected via-ldflags.Reviewer note: dragontoothmg king-capture guard
dragontoothmgwill generate a king-capturing move when handed a positionwhere the side not to move is in check, then panic on the empty king
bitboard at the next
GenerateLegalMoves.kingCaptureScoreplus guards inSearch/negamax/quiescemake the search robust to such positions. Thismatters because FEN and UCI input come from GUIs / tournament managers and are
untrusted (see
SECURITY.mdscope). These positions never arise from legalplay, so there is no search-quality impact.
Repository scaffold
README.md(badges + roadmap),CONTRIBUTING.md,SECURITY.md(supported-versions table, private reporting, response SLA),SUPPORT.md,MAINTAINERS.md(+ release process),CODE_OF_CONDUCT.md(Contributor Covenant 2.1),
CHANGELOG.md(Keep a Changelog),docs/architecture.md,docs/adr/0001+0002..github/:CODEOWNERS,dependabot.yml(gomod + actions + docker),PULL_REQUEST_TEMPLATE.md, issue-form templates, workflows:ci.yml— OS x Go matrix,-race, coverage,go mod tidycheck,govulnchecklint.yml—golangci-lint+gofumptcodeql.yml,release.yml(GoReleaser + SBOM)Makefile,.golangci.yml,.goreleaser.yaml, multi-stageDockerfile-> distroless,.dockerignore,.editorconfig,.gitattributes, updated.gitignore.Module / license
github.com/cjunius/goChess.dragontoothmg.go.sumhashes were taken from the Go checksum database;go mod tidyis ano-op.
Verification
Run locally with Go 1.23:
go build ./...,go vet ./...— cleango test -race ./...— pass, including deep perftgolangci-lint run(v1.61.0) — cleangofmt -l .— cleangochess perft 6matches reference counts; UCI loop plays legal movesChecklist
CHANGELOG.mdupdated under## [Unreleased]