▶ Play it here — no install, no sign-up, works offline once loaded.
Backgammon in the browser against four AI opponents, from a loose Beginner to an Expert neural network trained from scratch by self-play. One HTML file, no dependencies, no tracking.
One click moves a checker. Roll, then click any glowing checker — it moves by the highlighted die. That is the whole interaction. Everything else is optional:
| Action | How |
|---|---|
| Move a checker | Click it (moves by the highlighted die) — or drag it to the point you want |
| Use the other die first | Drop it on the point you want, click that die, press 1/2, or right-click the checker |
| See where it lands | Hover — a ghost shows the destination, a red ring means it hits |
| Roll | Click the dice area or press Space (auto-roll is on by default) |
| Take a move back | Undo in the top bar, or U |
| Ask for advice | Hint or H — draws the Expert's play as arrows |
| Double the stakes | Double or D (matches only) |
| Keyboard only | ←→ to pick a checker, Enter to move it |
| Help card | ? |
The coach explains each situation the first couple of times it comes up, then gets out of the way. Turn it off entirely with the Coach button in the top bar; a one-line status stays.
| Level | What it is | Result |
|---|---|---|
| Beginner | Simple evaluation, plays loosely and leaves blots | — |
| Casual | Counts pips, avoids obvious shots | beats Beginner ~96% |
| Strong | Full positional evaluator: primes, anchors, exact shot counts, timing | beats Casual ~83% |
| Expert | 198-40-1 neural network, trained by TD(λ) self-play over 400,000 games, searching one roll ahead | beats Strong ~71% |
The Expert also powers the Hint button and the bot's doubling-cube decisions. Its 8,001 weights are baked into the page as a 42 KB base64 blob, so the whole thing is still a single file that runs offline.
- Match play to 1, 3, 5, 7 or 11 points, with the doubling cube, the Crawford rule, gammons and backgammons
- Accuracy scorecard after every game: how often you found the best play, and your biggest slip
- Resume — close the tab mid-match and pick up exactly where you left off
- Three board themes, synthesized sound, adjustable pace, optional turn confirmation, and a Board highlights switch for a completely plain board
- Screen-reader live regions, visible focus,
prefers-reduced-motionsupport, and a rotated board for portrait phones
src/engine.js— the rules, as pure functions. Differential-fuzzed against an independently written move generator over 16,000 dice-positions with zero divergences: forced dice, the larger-die rule, bar entry, exact and overshoot bear-off, gammon and backgammon detection.src/ai.js— the heuristic evaluator behind Beginner/Casual/Strong. Antisymmetric by construction, with an exact 36-roll shot counter (mean error 0.00/36 against ground truth) and a race-aware cube.src/nn.js— the neural evaluator. Trained with temporal-difference learning on raw self-play, no human games and no opening book.src/app.js,src/styles.css— the interface.tools/build.mjs— inlines everything intodist/index.html.
Two rounds of adversarial review (177 findings, each one independently verified before it was fixed)
went into the release. See docs/DEVELOPMENT.md for the full process.
git clone https://github.com/WilburFort/backgammon.git
cd backgammon
node tools/build.mjs # writes dist/index.html and index.html
open index.html # or just double-click itNothing to install for the game or the tests — only the browser tests need Playwright.
npm test # rules + AI test suites (no dependencies)
npm run tournament # bot-vs-bot strength check
npm install && npm run e2e # real-browser playtest with real clicksMIT.
