Skip to content

Rebuild engine on dragontoothmg and add enterprise repo scaffold - #1

Merged
cjunius merged 1 commit into
mainfrom
feat/engine-on-dragontoothmg-and-repo-scaffold
Aug 30, 2026
Merged

cjunius merged 1 commit into
mainfrom
feat/engine-on-dragontoothmg-and-repo-scaffold

Conversation

@cjunius

@cjunius cjunius commented Aug 30, 2026

Copy link
Copy Markdown
Owner

What & why

Two things in one change:

  1. Replace the notnil/chess prototype with a real engine built on
    dylhunn/dragontoothmg, a
    magic-bitboard legal move generator. notnil/chess is convenient but
    allocation-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.
  2. Lay the repo out in the standard Go + enterprise-GitHub structure
    cmd/ + internal/, plus the full set of community/health files, CI, and
    release tooling.

Closes nothing (no tracking issue).

What changed

Engine

  • internal/engine
    • perft.go — thin wrappers over dragontoothmg.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.goEvaluate(*Board) int: material + Michniewski piece-square
      tables + 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. Emits info + bestmove, renders
    score mate N.
  • cmd/gochess — CLI: uci (default), perft <depth> [fen], bench,
    version. version/commit/date injected via -ldflags.

Reviewer note: dragontoothmg king-capture guard

dragontoothmg will generate a king-capturing move when handed a position
where the side not to move is in check, then panic on the empty king
bitboard at the next GenerateLegalMoves. kingCaptureScore plus guards in
Search/negamax/quiesce make the search robust to such positions. This
matters because FEN and UCI input come from GUIs / tournament managers and are
untrusted (see SECURITY.md scope). These positions never arise from legal
play, so there is no search-quality impact.

Repository scaffold

  • Docs: rewritten 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 tidy check,
      govulncheck
    • lint.ymlgolangci-lint + gofumpt
    • codeql.yml, release.yml (GoReleaser + SBOM)
  • Tooling: Makefile, .golangci.yml, .goreleaser.yaml, multi-stage
    Dockerfile -> distroless, .dockerignore, .editorconfig,
    .gitattributes, updated .gitignore.

Module / license

  • Module path: github.com/cjunius/goChess.
  • License stays GPL-3.0, which matches dragontoothmg.
  • go.sum hashes were taken from the Go checksum database; go mod tidy is a
    no-op.

Verification

Run locally with Go 1.23:

  • go build ./..., go vet ./... — clean
  • go test -race ./... — pass, including deep perft
  • golangci-lint run (v1.61.0) — clean
  • gofmt -l . — clean
  • gochess perft 6 matches reference counts; UCI loop plays legal moves

Checklist

  • Tests added (perft regression + search behavior + UCI)
  • Move-generation coverage via perft tests
  • CHANGELOG.md updated under ## [Unreleased]
  • Chess-strength match results — N/A (first real engine version; no prior baseline)

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
cjunius force-pushed the feat/engine-on-dragontoothmg-and-repo-scaffold branch from ee550f2 to 5106f79 Compare August 30, 2026 20:14
@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@codecov-commenter

Copy link
Copy Markdown

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 ☂️

@cjunius
cjunius merged commit 085d120 into main Aug 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants