From 241156da6f35cb888253e6b8814e7b61a76b4fc7 Mon Sep 17 00:00:00 2001 From: tslil Date: Sun, 30 Aug 2026 19:46:07 +0100 Subject: TD(lambda), and a big rework NOTE: 6x6 weights are as-yet untrained On the performance side: * switch from linked-list chaining hash table to direct mapping * cache check_win by hash * persist transposition tables across plies (this was a big deal and difficult to puzzle out) * add align directives to the network floats * prepare_nn_input gained a small LUT to avoid branching (i suppose you might call this 1D embedding) * apply mtune=native for the native builds On the correctness side: * Zobrist has now includes the ply parity * the network now predicts something in [-1, 1] using tanh (approximated by polynomials) * the training object is now MSE because we're learning a value estimate * use .clangd instead of compile_commands.json On the training side: * completely forgo human-derived data set * implement td(lambda), self-play, tournaments --- README.md | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8d1b437..3daa539 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,11 @@ ## Overview -Details forthcoming, but at a glance: - 1. ctak is a C library for the game of Tak -2. ctaklm is a line-mode interface to ctak and a computer opponent - (for 5x5) -3. ct1986 is a similar interface, but designed for a Raspberry Pi Zero - running buildroot and displaying output on a character LCD. +2. ctaklm is a line-mode interface to ctak and a computer opponent (for 5x5) +3. ct1986 is a similar interface, but designed for a Raspberry Pi Zero running buildroot and displaying output on a character LCD. +4. cttei is a TEI-speaking game engine for use wherever TEI is accepted. +5. geminict is a special adaptation of ctak for use in a gemini CGI web-server. ## Building for the native platform @@ -16,33 +14,15 @@ Details forthcoming, but at a glance: ## Building for the Raspberry Pi Zero -Download and extract a recent version of buildroot into the working -directory. Edit `BUILDROOT_DIR=buildroot-2020.11.1` in `Makefile` to -point to the extracted directory. +Download and extract a recent version of buildroot into the working directory. Edit `BUILDROOT_DIR=buildroot-2020.11.1` in `Makefile` to point to the extracted directory. make pi ## The computer opponent -Standard adversarial tree search (α-β negamax) with iterative deepening, using a neural network evaluation function for leaves and also transposition tables implemented using Zobrist hasing and a chaining hash table. - -The architecture of the neural network is a standard, two-layer dense classification network -``` -_________________________________________________________________ - Layer (type) Output Shape Param # -================================================================= - input_1 (InputLayer) [(None, 28)] 0 - - dense (Dense) (None, 64) 1856 - - dense_1 (Dense) (None, 2) 130 +Standard adversarial tree search (α-β negamax) with iterative deepening, using a neural network evaluation function for leaves and also a transposition table keyed on the Zobrist hash. -================================================================= -Total params: 1,986 -Trainable params: 1,986 -Non-trainable params: 0 -``` -which was trained on the binary classification problem of predicting the winner from a given board state. As input the network is fed the top layer of the board only (see nn1986.c for details) as well as `flats used/flats remaining` fractions for both players and a single float indicating the parity of the board. At the time of training, on the dataset given by `resources/extract.sh`, this achieves ~75% accuracy on the validation set. +The architecture of the neural network is a standard, two-layer dense network which is trained exclusively through self-play using td-leaf (see `src/nn_train.py`). As input the network is fed the top layer of the board only as well as `flats used/flats remaining` fractions for both players and a single float indicating the parity of the board. ## License -- cgit v1.3.1