Files
Rigby/Makefile
T
rektdieandclaude d3044c0b88 feat: minimal MCTS engine with UCI
Bitboard board with fancy magics and fully legal move generation, checked
by a perft suite. PUCT search over a node arena with FPU reduction and
in-tree draw detection. Hand-written value (eval + quiescence) and
heuristic policy stand in until the network is trained. UCI loop with a
search thread, OpenBench-compatible bench and Makefile.

Bench: 546127

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

85 lines
1.6 KiB
Makefile

# Rigby - MCTS chess engine
# OpenBench calls: make EXE=<name> [EVALFILE=<net>] [CXX=<compiler>]
SRC_DIR := src
OBJ_DIR := obj
EXE ?= Rigby
EVALFILE ?=
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
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
ifneq ($(EVALFILE),)
CXXFLAGS += -DEVALFILE=\"$(EVALFILE)\"
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)
-include $(DEPS)
.PHONY: clean
clean:
rm -rf $(OBJ_DIR) $(EXE)$(EXE_EXT)