Rapfi: Distilling Efficient Neural Network for the Game of Gomoku

Zhanggen Jin, Haobin Duan, Zhiyang Hang · 2025

Read Rapfi: Distilling Efficient Neural Network for the Game of Gomoku by Zhanggen Jin, Haobin Duan, Zhiyang Hang (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2503-13178.txt.

Introduction

Jin, Duan, and Hang built a lean game agent in twenty twenty-five for Gomoku, a five-in-a-row board game, that beats big net agents on small gear. Big net agents need vast compute to play at top strength. Their agent uses a small net with a book of board pat-terns drawn from big nets.

A step-by-step update trick cuts work when just a few stones change per move. That trick also speeds deep search by a large share. With tuned scores and search it beat the top open AlphaZero-like Gomoku agent sans fast chips. It ranked first in a large bot pool and won a known cup.

Catalog record

CREATORZhanggen Jin, Haobin Duan, Zhiyang Hang
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE42 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2503-13178

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Rapfi: Distilling Efficient Neural Network for the Game of Gomoku Zhanggen Jin, Haobin Duan, Zhiyang Hang 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. 1 1 footnotetext: These authors contributed equally to this work. 1 Introduction Artificial intelligence in board games like Go, Chess, and Shogi has progressed rapidly with the advent of deep neural networks. Notable examples include AlphaGo ( Silver et al. 2016 ) , AlphaGo Zero ( Silver et al. 2017b ) , Katago ( Wu 2019 ) , and other efforts in Chess ( Schrittwieser et al. 2020 ) and Shogi ( Silver et al. 2017a ; Schrittwieser et al. 2020 ; Nasu 2018 ) . These methods rely heavily on deep neural networks, requiring powerful accelerators like high-end GPUs. Our objective is to create a specialized network that maintains similar prediction accuracy but runs significantly faster, aiming to outperform current state-of-the-art solutions under constrained computation. Gomoku, a straightforward yet complex perfect information board game, that serves as an excellent benchmark for evaluating agent performance. Although Gomoku with free openings has been solved ( Allis et al. 1994 ) , achieving optimal play with arbitrary balanced openings remains challenging. Current methods often fail to exceed top human players or are computationally intensive. Therefore, we choose Gomoku as our testbed, as it demands precise position evaluation and deep tactical search, making the balance between evaluation and search critical. Deep models like convolutional neural networks (CNNs) are highly effective at predicting values and policies from 2D inputs, playing a crucial role in reinforcement learning. evaluating them can be computationally intensive. Our key observation is that, in board games with black and white stones, much of this computation is spent extracting features from local patterns. While CNNs excel at this, the process is often redundant, as features of the same patterns remain fixed, and most of the board doesn’t change during gameplay. By decomposing the board into local patterns and pre-computing their features, we can greatly reduce computational demands. To address this, we introduce a lightweight neural network named Mixnet , which requires far less computation than CNNs while maintaining comparable accuracy. Our method uses a pattern-based codebook derived from a larger network and includes an incremental update scheme that reduces computation further, especially with depth-first game tree traversal like Alpha-Beta search. We also introduce several improvements in the feed-forward process to enhance the accuracy of value and policy prediction. In summary, our contributions include: • We decompose a binary board plane into local line-shaped patterns and train a mapping network to convert these patterns into features. This network is then baked into a pattern-indexed codebook for instant lookup, reducing computation by orders of magnitude while maintaining fair evaluation accuracy. • We introduce an incremental update scheme that minimizes computation when only a few stones on the board change. This mechanism significantly speeds up processing, especially when combined with depth-first search algorithms. • We integrate several enhancements to optimize the feed-forward computation of value and policy heads, including dynamic policy convolution, value grouping, and star blocks, to improve evaluation accuracy without adding significant computational complexity. 2 Related Work 2.1 Efficient Neural Networks With the rapid advancement of computer vision, the landscape of neural network design has seen a surge in innovative architectures aimed at minimizing computational demands while maximizing performance. Notable designs include Mixtures of Experts (MoE) ( Jacobs et al. 1991 ) , MobileNets ( Howard et al. 2017 ; Sandler et al. 2018 ; Howard et al. 2019 ) , SENet ( Hu et al. 2018 ) , SKNets ( Li et al. 2019 ) and CondConv ( Yang et al. 2019 ) . These models are designed to improve both inference speed and prediction accuracy. Unlike the approaches mentioned above, our method takes a novel direction by precomputing a pattern-based feature lookup table and takes advantage of the incremental nature of the gameplay structure. We also incorporate structural improvements in the feedforward components of the network, including depth-wise and point-wise convolutions ( Zhang et al. 2020 ) , dynamic convolution ( Chen et al. 2020 ) , grouped average pooling, and the star operation ( Ma et al. 2024 ) . 2.2 Search Algorithms for Game Trees The most notable game tree search algorithms are Monte Carlo Tree Search (MCTS) ( Coulom 2006 ) and \alpha - \beta search ( Knuth & Moore 1975 ) . MCTS is commonly used by Go agents and has many variants that enhance its performance, such as UCT ( Gelly & Wang 2006 ) , RAVE ( Rimmel et al. 2010 ) , and EMCTS ( Cazenave 2007 ) . Additionally, parallel versions of MCTS ( Chaslot et al. 2008 ; Cazenave 2022 ) have improved search speed and efficiency on multi-core hardware. On the other hand, \alpha - \beta search has a long history with many enhancements, including futility pruning ( Heinz 1998 ; Hoki & Muramatsu 2012 ) , razoring ( Birmingham & Kent 1988 ) , null move pruning ( Donninger 1993 ; Hoki & Muramatsu 2012 ) , late move reduction ( Hoki & Muramatsu 2012 ) , and history reduction ( Schaeffer 1983 ) . For Gomoku, algorithms like proof-number search ( Allis et al. 1994 ) and threat-space search ( Allis et al. 1993 ) significantly reduce computation for proving positions and improving search efficiency in specific scenarios. Since the traversal order of the game tree may affect the inference speed of our proposed network, we evaluate it using both MCTS and \alpha - \beta search in our experiments. 2.3 Agents for the Game of Gomoku Gomoku is a two-player game featuring simple rules yet significant strategic depth, making it an excellent testbed for evaluating evaluation models and search techniques. Played on a 15x15 grid, players alternate placing black and white stones, with the black player starting first. The goal is to align five stones in a row—horizontally, vertically, or diagonally. If the board fills without a winner, the game ends in a draw. Research ( Alus et al. 1996 ) has shown that the first player can always achieve a win, but reaching optimal play from a balanced position remains a complex challenge, with many methods still

Read the complete text