Merge pull request 'Rename MCTS to MCGS' (#26) from mcgs-rename into main
src/mcts.* is now src/mcgs.*; the banner, Makefile header and README say MCGS. No behaviour change, no SPRT. Bench: 608763
This commit was merged in pull request #26.
This commit is contained in:
commit
19a67fbb94
6 files changed
+27
-20
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
# Rigby - MCTS chess engine
|
# Rigby - MCGS chess engine
|
||||||
# OpenBench calls: make EXE=<name> [EVALFILE=<net>] [CXX=<compiler>]
|
# OpenBench calls: make EXE=<name> [EVALFILE=<net>] [CXX=<compiler>]
|
||||||
# POLICYFILE=<net> picks the built-in policy network; POLICYFILE= builds none
|
# POLICYFILE=<net> picks the built-in policy network; POLICYFILE= builds none
|
||||||
# (move heuristics).
|
# (move heuristics).
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Rigby
|
# Rigby
|
||||||
|
|
||||||
Rigby is a UCI chess engine built on Monte Carlo Tree Search (PUCT). The goal is a
|
Rigby is a UCI chess engine built on Monte Carlo Graph Search (MCGS) with PUCT
|
||||||
neural-network-guided MCTS engine, later a Monte Carlo Graph Search (MCGS), with a
|
selection. The goal is a neural-network-guided MCGS engine with a value and policy
|
||||||
value and policy network trained with [bullet](https://github.com/jw1912/bullet) on
|
network trained with [bullet](https://github.com/jw1912/bullet) on
|
||||||
data generated by Leela Chess Zero, and CUDA inference.
|
data generated by Leela Chess Zero, and CUDA inference.
|
||||||
|
|
||||||
Every change is validated with SPRT on OpenBench.
|
Every change is validated with SPRT on OpenBench.
|
||||||
@@ -14,8 +14,14 @@ Every change is validated with SPRT on OpenBench.
|
|||||||
- Chess960: any castling rook placement, X-FEN and Shredder-FEN castling rights,
|
- Chess960: any castling rook placement, X-FEN and Shredder-FEN castling rights,
|
||||||
`UCI_Chess960` for king-takes-rook castling notation. Verified with the 960
|
`UCI_Chess960` for king-takes-rook castling notation. Verified with the 960
|
||||||
positions of the standard Chess960 perft suite to depth 5 (`perftfile`).
|
positions of the standard Chess960 perft suite to depth 5 (`perftfile`).
|
||||||
- PUCT search: node arena with contiguous children, first-play urgency reduction,
|
- Monte Carlo Graph Search: a position reached by different move orders is one
|
||||||
two-fold repetition, 50-move and insufficient-material draws inside the tree.
|
node, found through a key table. Edges carry their own visits, so a node's Q
|
||||||
|
is the visit-weighted mix of its children. PUCT selection with first-play
|
||||||
|
urgency reduction. A playout stops at a child that already has more visits
|
||||||
|
than the edge leading to it and backs up that child's Q.
|
||||||
|
- Repetition and 50-move draws depend on the path, so they are counted only on
|
||||||
|
the edges of the current path, never stored in nodes. Insufficient-material
|
||||||
|
draws are terminal nodes.
|
||||||
- Value: a `(768 -> 128)x2 -> 1` network trained with bullet on Lc0 data
|
- Value: a `(768 -> 128)x2 -> 1` network trained with bullet on Lc0 data
|
||||||
(`networks/rigby-value-v1.bin`, embedded at build time; see `train/README.md`),
|
(`networks/rigby-value-v1.bin`, embedded at build time; see `train/README.md`),
|
||||||
behind a capture-only quiescence search.
|
behind a capture-only quiescence search.
|
||||||
@@ -23,11 +29,11 @@ Every change is validated with SPRT on OpenBench.
|
|||||||
(`networks/rigby-policy-v1.bin`, embedded at build time; see `train/README.md`).
|
(`networks/rigby-policy-v1.bin`, embedded at build time; see `train/README.md`).
|
||||||
Built without one (`POLICYFILE=`), move heuristics (captures, promotions,
|
Built without one (`POLICYFILE=`), move heuristics (captures, promotions,
|
||||||
checks, pawn threats).
|
checks, pawn threats).
|
||||||
- Tree reuse between moves: the subtree of the new position is packed to the
|
- Graph reuse between moves: only the root moves to the new position. The next
|
||||||
front of the node arena in place, so it costs no extra memory.
|
collection keeps what the root reaches.
|
||||||
- When the arena is full, the least visited parts of the tree are cut back to
|
- When the node or edge arena is full, the least visited parts of the graph are
|
||||||
leaves (keeping their visits and Q) and the rest is packed, so search never
|
cut back to leaves (keeping their visits and Q), the rest is packed in place
|
||||||
stops expanding.
|
and the key table is rebuilt, so search never stops expanding.
|
||||||
- Single-threaded.
|
- Single-threaded.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
@@ -44,9 +50,10 @@ make EVALFILE=path/to/quantised.bin
|
|||||||
`EVALFILE` defaults to `networks/rigby-value-v1.bin`. `POLICYFILE` defaults to
|
`EVALFILE` defaults to `networks/rigby-value-v1.bin`. `POLICYFILE` defaults to
|
||||||
`networks/rigby-policy-v1.bin`; `POLICYFILE=` builds the move heuristics instead.
|
`networks/rigby-policy-v1.bin`; `POLICYFILE=` builds the move heuristics instead.
|
||||||
|
|
||||||
Compiling with `-DRIGBY_VERIFY_TREE` checks the whole tree before and after every
|
Compiling with `-DRIGBY_VERIFY_TREE` checks the whole graph before and after every
|
||||||
reuse and after every collection (legal moves, visit counts) and aborts on the first
|
reuse and after every collection (legal moves, visit counts, keys and the key table)
|
||||||
inconsistency. It is slow, for debugging only.
|
and aborts on the first inconsistency. Such a build also has a `verify` command that
|
||||||
|
runs these checks on test positions. It is slow, for debugging only.
|
||||||
|
|
||||||
## UCI
|
## UCI
|
||||||
|
|
||||||
@@ -84,7 +91,7 @@ terminal).
|
|||||||
|
|
||||||
| Option | Default | Meaning |
|
| Option | Default | Meaning |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| Hash | 64 | Tree memory in MB. A node takes 20 bytes. |
|
| Hash | 64 | Graph memory in MB: 32-byte nodes, 16-byte edges and the key table. |
|
||||||
| Threads | 1 | Only 1 for now. |
|
| Threads | 1 | Only 1 for now. |
|
||||||
| MoveOverhead | 20 | Milliseconds kept back per move. |
|
| MoveOverhead | 20 | Milliseconds kept back per move. |
|
||||||
| CPuct | 160 | Exploration constant x100. |
|
| CPuct | 160 | Exploration constant x100. |
|
||||||
@@ -97,5 +104,5 @@ terminal).
|
|||||||
## Bench
|
## Bench
|
||||||
|
|
||||||
`Rigby bench` runs 5000 playouts on each of 16 positions. The reported node count is
|
`Rigby bench` runs 5000 playouts on each of 16 positions. The reported node count is
|
||||||
the number of positions visited in the tree over all playouts, so it changes
|
the number of positions visited in the graph over all playouts, so it changes
|
||||||
whenever search behaviour changes, while the playout count stays fixed.
|
whenever search behaviour changes, while the playout count stays fixed.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "mcts.h"
|
#include "mcgs.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
@@ -153,7 +153,7 @@ private:
|
|||||||
void rebuild_table();
|
void rebuild_table();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Butterfly history for MCTS (after Vine, aronpetkovski.com/blog/butterfly-history-mcts):
|
// Butterfly history (after Vine, aronpetkovski.com/blog/butterfly-history-mcts):
|
||||||
// every playout scores each move on its path with the playout's result, and
|
// every playout scores each move on its path with the playout's result, and
|
||||||
// the score is added to the move's policy logit when a node is expanded.
|
// the score is added to the move's policy logit when a node is expanded.
|
||||||
class ButterflyHistory {
|
class ButterflyHistory {
|
||||||
+1
-1
@@ -437,7 +437,7 @@ std::string banner(const std::string& name, const std::string& version, const st
|
|||||||
Line title;
|
Line title;
|
||||||
title.add(name, TITLE).add(" " + version, VALUE);
|
title.add(name, TITLE).add(" " + version, VALUE);
|
||||||
Line right;
|
Line right;
|
||||||
right.add("MCTS chess engine", LABEL);
|
right.add("MCGS chess engine", LABEL);
|
||||||
box.top(title, right);
|
box.top(title, right);
|
||||||
box.row(Line{});
|
box.row(Line{});
|
||||||
Line by;
|
Line by;
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
#include "mcts.h"
|
#include "mcgs.h"
|
||||||
#include "perft.h"
|
#include "perft.h"
|
||||||
#include "policy.h"
|
#include "policy.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
|
|||||||
Reference in new issue
Block a user