Files
Rigby/Makefile
T
rektdieandclaude c4f65b2632 feat: policy network v1 replaces the move heuristics
networks/rigby-policy-v1.bin is now built in by default (POLICYFILE;
POLICYFILE= still builds the heuristics). It is a 3072 -> 1024 -> 3920
network trained by train/policy on 171M positions of Lc0 test91
self-play (2026-10-25 .. 11-15) against the search's visit
distributions: 10 superbatches of 100M, 10 minutes on the RTX 3070,
final loss 2.296 (2.39 after the first superbatch). The butterfly
history bias and PolicyTemp apply on top of its logits as they did on
the heuristics' scores.

Sensible priors: 1.e4 e5 75%, Kiwipete Bxa6 38%, black bxc3 43%,
c8=Q in the K+P ending. The engine's quantised output matches the
trainer's float output to tenths of a percent, a few percent on very
sharp distributions. Costs about 10% nps on the bench.

Checked: bench deterministic; RIGBY_VERIFY_TREE build driven over UCI
(Hash 1 MB, repeated positions, fen + moves, wtime/winc, go infinite +
stop) without an abort; a build with POLICYFILE= gives the old bench
529903.

Bench: 630039

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:16:58 +01:00

97 lines
2.1 KiB
Makefile

# Rigby - MCTS chess engine
# OpenBench calls: make EXE=<name> [EVALFILE=<net>] [CXX=<compiler>]
# POLICYFILE=<net> picks the built-in policy network; POLICYFILE= builds none
# (move heuristics).
SRC_DIR := src
OBJ_DIR := obj
EXE ?= Rigby
# The value network embedded into the binary
EVALFILE ?= networks/rigby-value-v1.bin
# The policy network embedded into the binary; empty means move heuristics
POLICYFILE ?= networks/rigby-policy-v1.bin
CXX ?= clang++
ifeq ($(origin CXX),default)
CXX := clang++
endif
ifeq ($(OS),Windows_NT)
EXE_EXT := .exe
PLATFORM := windows
else
EXE_EXT :=
UNAME_S := $(shell uname -s)
ARCH := $(shell uname -m)
ifeq ($(UNAME_S),Darwin)
PLATFORM := mac
else
PLATFORM := unix
endif
endif
CXXFLAGS := -std=c++20 -O3 -flto -Wall -Wextra -DNDEBUG -Iexternal
LDFLAGS := -O3 -flto
ifeq ($(PLATFORM),windows)
ARCH_FLAGS := -march=native
# clang on Windows defaults to MSVC; use the MinGW runtime like Eleanor does.
ifneq ($(findstring clang,$(CXX)),)
CXXFLAGS += --target=x86_64-w64-windows-gnu
LDFLAGS += --target=x86_64-w64-windows-gnu
endif
CXXFLAGS += -pthread
LDFLAGS += -pthread -static
else ifeq ($(PLATFORM),mac)
ifeq ($(ARCH),arm64)
ARCH_FLAGS := -mcpu=apple-m1
else
ARCH_FLAGS := -march=native
endif
CXXFLAGS += -pthread
LDFLAGS += -pthread
else
ifeq ($(ARCH),aarch64)
ARCH_FLAGS := -mcpu=native
else
ARCH_FLAGS := -march=native
endif
CXXFLAGS += -pthread
LDFLAGS += -pthread -static
endif
CXXFLAGS += -DEVALFILE=\"$(EVALFILE)\"
ifneq ($(POLICYFILE),)
CXXFLAGS += -DPOLICYFILE=\"$(POLICYFILE)\"
endif
CXXFLAGS += $(ARCH_FLAGS)
LDFLAGS += $(ARCH_FLAGS)
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS))
DEPS := $(OBJS:.o=.d)
MAKEFLAGS += -j
$(EXE)$(EXE_EXT): $(OBJS)
$(CXX) $^ -o $@ $(LDFLAGS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
$(OBJ_DIR):
mkdir $(OBJ_DIR)
# Rebuild the network's translation unit when the network changes
$(OBJ_DIR)/nnue.o: $(EVALFILE)
ifneq ($(POLICYFILE),)
$(OBJ_DIR)/policy.o: $(POLICYFILE)
endif
-include $(DEPS)
.PHONY: clean
clean:
rm -rf $(OBJ_DIR) $(EXE)$(EXE_EXT)