About zxGammon
zxGammon is backgammon for the 48K ZX Spectrum. You play against Gnubby, a little gnu with a neural-network player for a brain: money games, or matches to 1, 3, 5 or 7 points, with the doubling cube and the Crawford rule. It runs on a real Spectrum, in any Spectrum emulator, and on this site's front page.
How Gnubby plays
All of Gnubby's play is in Z80 code with no multiplication or division: about 29 KB of code and data for the engine, the network's weights among them, and the whole game about 38 KB.
- Every legal move is generated, each resulting position once.
- Each is scored by a neural network that sees only the board: 64 units that keep their sums as the checkers move, products of those units in pairs, and a small network of its own for each kind of position (contact, crashed or race), giving the chances of winning, of gammons and of backgammons. (With more than 99 moves, a fast linear filter picks the 99 to score.)
- The best few, while time allows, are each tried against all 21 of the opponent's rolls, the opponent's reply chosen by the filter and the position after it scored by the network; the best on average wins.
- For the cube, Gnubby works out his equity with the cube from the network's chances, by Janowski's formula as GNU Backgammon does, in a match through GNU Backgammon's match equity table. When it is close he looks a move deeper.
On a 3.5 MHz Spectrum a move takes Gnubby about five and a half seconds on average, and a decision about the cube about a second.
GNU Backgammon
zxGammon's play is derived from GNU Backgammon, the free backgammon program of the GNU Project, and owes it everything about how well Gnubby plays:
- Its neural network is derived from GNU Backgammon's: it scores positions as GNU Backgammon does, and so does its move filter.
- Its doubling cube follows GNU Backgammon: Janowski's formula with GNU Backgammon's cube efficiencies, and in a match GNU Backgammon's match equity table at the score and cube.
GNU Backgammon is free software, licensed under the GNU General Public License, and so is zxGammon.
Licence
zxGammon, Copyright © 2026 Paul Hankin.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
That covers the whole of this site: the game and its source, the networks' weights, its pictures, and the pages and Spectrum emulator here (js/z80.js, js/spectrum.js, js/main.js). The source is on the Source pages, ready to build with the open-source assembler sjasmplus.
While you look at the site's other pages, your game is kept where it was, in your browser tab's own storage, and goes when you close the tab or press Restart. Nothing is sent anywhere: the site has no server code, and the one cookie it sets only records that you have seen the notice on your first visit.
ZX Spectrum is a trademark of its owners; zxGammon is not connected with them. The emulator here needs no Spectrum ROM: zxGammon reads the keyboard and draws the screen itself.