About

by , , and

Our model, HexNet, is a neural network $M_\theta$ parametrized by weight vector $\theta$, that takes as input a board configuration $c$ and outputs a value $v_\theta(c) \in [-1,1]$ and stochastic policy $\pi_\theta(c) \in [0,1]^N$, where $N$ is the number of board cells.

The main training loop is as follows. More details on the neural network and the tree search appear afterwards.


Repeat for multiple rounds:

  1. Freeze the network and play 48 complete self-play games, using tree search guided by the frozen network.
  2. Save training examples $(c_i,t_i,w_i)$, $i = 1,2,\dots$, where:
    • $c_i$ is the position.
    • $t_i$ is the policy target, the search visit distribution.
    • $w_i \in \{-1,+1\}$ is the eventual game outcome from the perspective of the player to move at $c_i$: $+1$ for a win and $-1$ for a loss.
  3. Repeat the following 80 times: sample a fresh minibatch $B$ of 512 examples uniformly with replacement from the replay buffer, which contains examples from this round and earlier rounds. Take one optimizer step on the loss function $$ \mathcal{L}_B(\theta) = \frac{1}{|B|} \sum_{i \in B} \left[ \bigl(v_\theta(c_i)-w_i\bigr)^2 + \mathrm{D}_{\mathrm{KL}}\!\left( t_i \,\|\, \pi_\theta(c_i) \right) \right] $$ with learning rate $\alpha = 0.002$ and the Adam optimizer.

Neural network

For an $11 \times 11$ board, two input planes pass through a shared trunk of convolutions. The trunk then branches into a policy head, which scores moves, and a value head, which evaluates the position.

Input c: 2 channels, each 11 × 11
channel 1: my stones · channel 2: opponent’s stones
Stem 1,280 parameters 64 × (2 × 3 × 3 + 2) = 1,280 (No. of output channels) × (convolution filter size + 2) The +2 is for BatchNorm’s scale and shift
3 × 3 convolution · 2 → 64 channels
BatchNorm → ReLU
Residual block × 8 73,984 parameters each 64 × (3 × 3 × 64 + 2) × 2 = 73,984 · 591,872 total
Eight blocks in sequence, each with its own weights
Inside one residual block The input goes through a 3 by 3 convolution, batch normalization and ReLU, then another 3 by 3 convolution and batch normalization. An identity shortcut adds the original input elementwise before a final ReLU. Both convolutions preserve all 64 channels and the 11 by 11 spatial dimensions. Identity shortcut 3 × 3 conv · 64 → 64 BatchNorm → ReLU 3 × 3 conv · 64 → 64 BatchNorm ReLU Inside one residual block A 3 by 3 convolution, batch normalization and ReLU are followed by another 3 by 3 convolution and batch normalization. The original input is added through an identity shortcut, followed by ReLU. All operations preserve the 64 by 11 by 11 tensor shape. Identity shortcut 3 × 3 conv · 64 → 64 BatchNorm → ReLU 3 × 3 conv · 64 → 64 BatchNorm ReLU
Policy head 65 parameters 64 + 1 = 65, where +1 is from bias

1 × 1 convolution
64 → 1 channel

121 move scores One score per cell. Mask occupied cells,
then softmax → policy πθ(c).
Value head 3,665 parameters (64 + 1) × 16 + (80 + 1) × 32 + (32 + 1) = 3,665, where +1 is from bias

1 × 1 convolution
64 → 16 channels · 16 × 11 × 11

5 averages per map → 80 numbers
Whole board + top, bottom, left, right edges

Dense 80 → 32 → 1
ReLU after 32 · tanh after 1

1 position value vθ(c) ∈ [−1, +1]
From the player-to-move’s perspective
HexNet · 596,882 learned parameters. Shapes are channels × rows × columns; convolution sizes are spatial kernel sizes. The trunk preserves the 11 × 11 grid. The ⊕ adds tensors elementwise.

Tree search uses the frozen network to look ahead from a position $c$. Each simulation selects a path, evaluates its endpoint, expands its legal replies, and backs the value up the path. Repeating this process updates the search statistics while the network weights $\theta$ stay fixed.

Write $n(c)$ for a position’s visit count, $W(c)$ for its accumulated backed-up value, and $Q(c)=W(c)/n(c)$ for its average value, measured from the player-to-move’s perspective; set $Q(c)=0$ when $n(c)=0$. For a child $d$ of $c$, let $P(d)$ be the prior assigned to its move by $\pi_\theta(c)$. Selection follows the child with the largest PUCT score:

$$\operatorname{score}(c \to d) = -Q(d) + 1.5\,P(d)\,\frac{\sqrt{n(c)}}{1+n(d)}.$$

The first term favors moves with good observed values; the second encourages exploring moves with a high prior and relatively few visits. The minus sign converts the child’s value to its parent’s viewpoint. In the example below, the root has already been evaluated and expanded; its three children start with zero visits and $Q=0$.

Loading the tree-search walkthrough…

This example uses a tiny fixed game and lookup predictions in place of $M_\theta$, and shows eight simulations rather than the training run’s 160 per searched turn. It omits Dirichlet root noise, Gumbel candidate ordering, and opening-move sampling. Actual training reserves up to 16 simulations for distinct unvisited root moves before PUCT takes over. It also reuses subtrees, batches network calls, and checks immediate wins and forced blocks.