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>]
|
||||
# POLICYFILE=<net> picks the built-in policy network; POLICYFILE= builds none
|
||||
# (move heuristics).
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Rigby
|
||||
|
||||
Rigby is a UCI chess engine built on Monte Carlo Tree Search (PUCT). The goal is a
|
||||
neural-network-guided MCTS engine, later a Monte Carlo Graph Search (MCGS), with a
|
||||
value and policy network trained with [bullet](https://github.com/jw1912/bullet) on
|
||||
Rigby is a UCI chess engine built on Monte Carlo Graph Search (MCGS) with PUCT
|
||||
selection. The goal is a neural-network-guided MCGS engine with a value and policy
|
||||
network trained with [bullet](https://github.com/jw1912/bullet) on
|
||||
data generated by Leela Chess Zero, and CUDA inference.
|
||||
|
||||
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,
|
||||
`UCI_Chess960` for king-takes-rook castling notation. Verified with the 960
|
||||
positions of the standard Chess960 perft suite to depth 5 (`perftfile`).
|
||||
- PUCT search: node arena with contiguous children, first-play urgency reduction,
|
||||
two-fold repetition, 50-move and insufficient-material draws inside the tree.
|
||||
- Monte Carlo Graph Search: a position reached by different move orders is one
|
||||
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
|
||||
(`networks/rigby-value-v1.bin`, embedded at build time; see `train/README.md`),
|
||||
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`).
|
||||
Built without one (`POLICYFILE=`), move heuristics (captures, promotions,
|
||||
checks, pawn threats).
|
||||
- Tree reuse between moves: the subtree of the new position is packed to the
|
||||
front of the node arena in place, so it costs no extra memory.
|
||||
- When the arena is full, the least visited parts of the tree are cut back to
|
||||
leaves (keeping their visits and Q) and the rest is packed, so search never
|
||||
stops expanding.
|
||||
- Graph reuse between moves: only the root moves to the new position. The next
|
||||
collection keeps what the root reaches.
|
||||
- When the node or edge arena is full, the least visited parts of the graph are
|
||||
cut back to leaves (keeping their visits and Q), the rest is packed in place
|
||||
and the key table is rebuilt, so search never stops expanding.
|
||||
- Single-threaded.
|
||||
|
||||
## Building
|
||||
@@ -44,9 +50,10 @@ make EVALFILE=path/to/quantised.bin
|
||||
`EVALFILE` defaults to `networks/rigby-value-v1.bin`. `POLICYFILE` defaults to
|
||||
`networks/rigby-policy-v1.bin`; `POLICYFILE=` builds the move heuristics instead.
|
||||
|
||||
Compiling with `-DRIGBY_VERIFY_TREE` checks the whole tree before and after every
|
||||
reuse and after every collection (legal moves, visit counts) and aborts on the first
|
||||
inconsistency. It is slow, for debugging only.
|
||||
Compiling with `-DRIGBY_VERIFY_TREE` checks the whole graph before and after every
|
||||
reuse and after every collection (legal moves, visit counts, keys and the key table)
|
||||
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
|
||||
|
||||
@@ -84,7 +91,7 @@ terminal).
|
||||
|
||||
| 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. |
|
||||
| MoveOverhead | 20 | Milliseconds kept back per move. |
|
||||
| CPuct | 160 | Exploration constant x100. |
|
||||
@@ -97,5 +104,5 @@ terminal).
|
||||
## Bench
|
||||
|
||||
`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.
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "mcts.h"
|
||||
#include "mcgs.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
@@ -153,7 +153,7 @@ private:
|
||||
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
|
||||
// the score is added to the move's policy logit when a node is expanded.
|
||||
class ButterflyHistory {
|
||||
+1
-1
@@ -437,7 +437,7 @@ std::string banner(const std::string& name, const std::string& version, const st
|
||||
Line title;
|
||||
title.add(name, TITLE).add(" " + version, VALUE);
|
||||
Line right;
|
||||
right.add("MCTS chess engine", LABEL);
|
||||
right.add("MCGS chess engine", LABEL);
|
||||
box.top(title, right);
|
||||
box.row(Line{});
|
||||
Line by;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "eval.h"
|
||||
#include "mcts.h"
|
||||
#include "mcgs.h"
|
||||
#include "perft.h"
|
||||
#include "policy.h"
|
||||
#include "position.h"
|
||||
|
||||
Reference in new issue
Block a user