Table of Contents
Fetching ...

Rapfi: Distilling Efficient Neural Network for the Game of Gomoku

Zhanggen Jin, Haobin Duan, Zhiyang Hang

TL;DR

Rapfi addresses the need for fast, accurate Gomoku agents on CPU-only hardware by distilling a pattern-aware Mixnet from CNNs into a pattern-indexed codebook with an incremental update mechanism. This design replaces heavy convolutional feature extraction with precomputed local pattern features and efficient updates during board changes, complemented by dynamic policy convolution, value grouping, and star pooling in the heads. Experimental results show Mixnet matches large CNNs in evaluation quality while delivering orders-of-magnitude faster inference, enabling effective search-based play; combined with Alpha-Beta search, Rapfi achieves state-of-the-art performance under constrained resources and won Botzone and GomoCup 2024. The work highlights how pattern decomposition, precomputed feature lookups, and targeted head enhancements can yield practical, high-performance game AIs suitable for real-time or resource-limited deployment.

Abstract

Games have played a pivotal role in advancing artificial intelligence, with AI agents using sophisticated techniques to compete. Despite the success of neural network based game AIs, their performance often requires significant computational resources. In this paper, we present Rapfi, an efficient Gomoku agent that outperforms CNN-based agents in limited computation environments. Rapfi leverages a compact neural network with a pattern-based codebook distilled from CNNs, and an incremental update scheme that minimizes computation when input changes are minor. This new network uses computation that is orders of magnitude less to reach a similar accuracy of much larger neural networks such as Resnet. Thanks to our incremental update scheme, depth-first search methods such as the alpha-beta search can be significantly accelerated. With a carefully tuned evaluation and search, Rapfi reached strength surpassing Katagomo, the strongest open-source Gomoku AI based on AlphaZero's algorithm, under limited computational resources where accelerators like GPUs are absent. Rapfi ranked first among 520 Gomoku agents on Botzone and won the championship in GomoCup 2024.

Rapfi: Distilling Efficient Neural Network for the Game of Gomoku

TL;DR

Rapfi addresses the need for fast, accurate Gomoku agents on CPU-only hardware by distilling a pattern-aware Mixnet from CNNs into a pattern-indexed codebook with an incremental update mechanism. This design replaces heavy convolutional feature extraction with precomputed local pattern features and efficient updates during board changes, complemented by dynamic policy convolution, value grouping, and star pooling in the heads. Experimental results show Mixnet matches large CNNs in evaluation quality while delivering orders-of-magnitude faster inference, enabling effective search-based play; combined with Alpha-Beta search, Rapfi achieves state-of-the-art performance under constrained resources and won Botzone and GomoCup 2024. The work highlights how pattern decomposition, precomputed feature lookups, and targeted head enhancements can yield practical, high-performance game AIs suitable for real-time or resource-limited deployment.

Abstract

Games have played a pivotal role in advancing artificial intelligence, with AI agents using sophisticated techniques to compete. Despite the success of neural network based game AIs, their performance often requires significant computational resources. In this paper, we present Rapfi, an efficient Gomoku agent that outperforms CNN-based agents in limited computation environments. Rapfi leverages a compact neural network with a pattern-based codebook distilled from CNNs, and an incremental update scheme that minimizes computation when input changes are minor. This new network uses computation that is orders of magnitude less to reach a similar accuracy of much larger neural networks such as Resnet. Thanks to our incremental update scheme, depth-first search methods such as the alpha-beta search can be significantly accelerated. With a carefully tuned evaluation and search, Rapfi reached strength surpassing Katagomo, the strongest open-source Gomoku AI based on AlphaZero's algorithm, under limited computational resources where accelerators like GPUs are absent. Rapfi ranked first among 520 Gomoku agents on Botzone and won the championship in GomoCup 2024.

Paper Structure

This paper contains 26 sections, 10 equations, 7 figures, 3 tables.

Figures (7)

  • Figure 1: The architecture overview of MixNet. It first decomposes a binary board input into local line patterns, then uses a mapping network to generate directional feature maps, which are stored in a pattern-indexed codebook after training. An aggregation and depth-wise $3\times3$ convolution are applied with an incremental update mechanism to produce the final feature map. Finally, a policy head and value head predict the policy and win rate in a feed-forward manner.
  • Figure 2: Left: Line patterns in four directions on a $15 \times 15$ board. By applying the mapping functions $M_{hv}$ and $M_{di}$ on these patterns, we obtain four features at this point, which are aggregated by summing and applying a ReLU activation to produce the final feature. Right: Convolution kernels for horizontal, vertical, main diagonal, and anti-diagonal patterns.
  • Figure 3: Left: The mapping network takes a board plane and outputs four directional pattern feature maps. Right: The incremental updateable parts of $\textit{Mixnet}$, which includes aggregation of four directional features and a depth-wise $3 \times 3$ convolution layer that operators on half of the channels.
  • Figure 4: Structure of the policy head and the value head.
  • Figure 5: ELO of all models given a fixed move time of Monte Carlo Tree Search.
  • ...and 2 more figures