1. Introduction: When Machines Learned Gomoku

Gomoku โ€” the deceptively simple game of placing stones to form five in a row โ€” has been a testing ground for artificial intelligence research for over half a century. Its clean rules, finite board, and perfect-information nature make it an ideal candidate for computer analysis, yet the game's immense search space (roughly 10105 possible game states on a standard 15ร—15 board) ensures that brute-force solutions are not trivially achievable.

The relationship between Gomoku and AI is richer than most people realize. Long before DeepMind's AlphaGo captivated the world by defeating a Go champion in 2016, computer scientists were already wrestling with Gomoku โ€” and succeeding. In 1994, Victor Allis, a Dutch computer scientist, proved definitively that freestyle Gomoku on a 15ร—15 board is a first-player win, making it one of the most complex games ever formally "solved."

This article traces the full arc of Gomoku AI: from the earliest programs of the 1970s through the classical algorithms that powered competitive engines, to the modern era of deep learning and neural network approaches. Whether you are a programmer curious about game AI, a Gomoku player who wants to understand how engines evaluate positions, or a computer science student looking for a tractable research domain, this guide provides a comprehensive overview of how computers learned to master Five in a Row.

If you are new to Gomoku itself, we recommend reading our complete rules guide and strategy guide first. Understanding the game's tactical vocabulary โ€” open threes, open fours, double threats, and standard openings โ€” will make the algorithmic concepts discussed here much more concrete.

๐Ÿ”‘ Key Takeaway: Gomoku occupies a unique position in AI research. It is complex enough to resist naive brute-force approaches, yet structured enough that researchers have been able to solve it completely and build engines that play at superhuman levels. This makes it an ideal bridge between simple solved games (like Tic-Tac-Toe) and unsolved games of extraordinary complexity (like Go).

2. Is Gomoku a Solved Game?

Yes โ€” freestyle Gomoku on a standard 15ร—15 board is a solved game. This landmark result was achieved by Victor Allis in his 1994 PhD thesis at the University of Maastricht, titled "Searching for Solutions in Games and Artificial Intelligence." Allis proved that with optimal play, the first player (Black) can always force a win.

The Strategy-Stealing Argument

Before Allis's computational proof, mathematicians had already established through a technique called the strategy-stealing argument that Gomoku could never be a second-player win. The reasoning is elegant: suppose White has a winning strategy. Then Black could simply "steal" that strategy by making an arbitrary first move and then playing as if it were the second player. The extra stone on the board can never be a disadvantage in Gomoku (unlike chess, where tempo matters), so Black would win โ€” contradicting the assumption. This means only two outcomes are possible: either the first player wins with optimal play, or the game is a draw.

๐Ÿงฎ Mathematical Proof: The strategy-stealing argument proves that Gomoku cannot be a second-player win by contradiction. If White had a winning strategy, Black could copy it while retaining the advantage of having an extra stone. Therefore, the game is either a first-player win or a draw. Allis's 1994 computer-assisted proof eliminated the draw possibility, confirming the first-player win.

Victor Allis and the 1994 Proof

Allis did not solve Gomoku by exhaustively searching every possible game โ€” that would be computationally infeasible even today. Instead, he developed an ingenious approach combining threat-space search with knowledge-based reasoning. His program identified chains of forcing moves (threats) that the first player can execute to guarantee victory. By systematically enumerating these threat sequences and proving that they covered all possible defensive responses, Allis demonstrated that Black can always win.

Specifically, Allis proved that Black wins by starting in the center of a 15ร—15 board, and his analysis held for all possible White responses. The proof relied on several key innovations:

What "Solved" Really Means

It is important to understand that "solved" means the theoretical outcome with perfect play is known โ€” not that every possible position has been evaluated. The game tree of Gomoku is far too large for a complete enumeration. What Allis showed is that there exists a strategy for Black that wins against any defense White can mount. In practice, most human games do not follow anywhere near optimal play, so Gomoku remains a rich, engaging experience despite being theoretically solved.

For more on Gomoku's fascinating mathematical history, see our comprehensive history article, which traces the game from its ancient Chinese origins to this landmark computer science achievement.

๐Ÿ’ป Solved Games in Context: Gomoku joins a select group of solved non-trivial games, including Checkers (solved by Jonathan Schaeffer's Chinook in 2007 as a draw), Connect Four (first-player win, solved by Victor Allis in 1988), and Nine Men's Morris (draw, solved in 1993). In terms of complexity, Gomoku's game-tree is significantly larger than Connect Four's, making its solution a major achievement.

3. Early Gomoku Programs (1970sโ€“1990s)

The history of computer Gomoku stretches back to the earliest decades of AI research. As soon as computers became powerful enough to play simple board games, researchers recognized Gomoku as an attractive target: its rules are simpler than chess, yet it requires strategic depth that goes well beyond Tic-Tac-Toe.

The 1970s: First Attempts

The earliest Gomoku programs appeared in the 1970s, typically running on mainframes at universities. These programs used straightforward search algorithms with hand-crafted evaluation functions. They could beat casual players but were no match for experienced competitors. The primary challenge was the enormous branching factor: on a 15ร—15 board, there are 225 possible first moves and up to 224 responses, creating a combinatorial explosion that quickly exceeded the computational resources of the era.

Early approaches typically evaluated positions by counting and weighting stone patterns โ€” for instance, awarding points for open threes, open fours, and combinations thereof. These pattern-based heuristics, while crude by modern standards, captured the fundamental tactical logic of Gomoku and remain the foundation of many engines today.

The 1980s: Growing Sophistication

Through the 1980s, Gomoku programs became significantly stronger as researchers incorporated more sophisticated search techniques. Alpha-beta pruning (which we discuss in detail below) enabled programs to search deeper into the game tree by eliminating provably irrelevant branches. Move ordering heuristics โ€” examining the most promising moves first โ€” further improved search efficiency.

The Computer Olympiad, first held in 1989, provided a competitive venue for Gomoku programs to test their strength against each other. These tournaments spurred rapid improvement and established benchmarks for measuring progress. Programs like Polygon and early versions of Yixin demonstrated that computers could play at a level competitive with strong human players.

The 1990s: The Breakthrough Decade

The 1990s was the transformative decade for Gomoku AI. Victor Allis's 1994 proof that the game is a first-player win was the crowning achievement, but it was accompanied by a broader surge in algorithmic innovation. Threat-space search, developed by Allis and others, proved particularly effective for Gomoku because the game's tactical nature means that forcing sequences are extremely common and can often be carried to completion.

By the late 1990s, the strongest Gomoku programs could consistently defeat all but the very best human players. The gap between human and machine was closing rapidly, and the stage was set for the algorithmic refinements and neural network approaches that would define the next era.

4. Key Algorithms Used in Gomoku AI

Gomoku AI draws on a rich toolkit of algorithms from computer science and artificial intelligence. Each technique addresses a different aspect of the challenge: searching the game tree efficiently, identifying tactical threats, evaluating non-terminal positions, and managing computational resources. Below we explore the four most important algorithmic families.

4.1 Minimax with Alpha-Beta Pruning

The minimax algorithm is the foundation of nearly all classical game-playing programs. The concept is simple: assume both players play optimally. The maximizing player (Black) tries to maximize the evaluation score, while the minimizing player (White) tries to minimize it. The algorithm recursively explores the game tree, alternating between maximizing and minimizing at each level, until it reaches a terminal state (win, loss, or draw) or a depth limit.

In its pure form, minimax is impractical for Gomoku because the branching factor (typically 200+ legal moves per position) is far too large. This is where alpha-beta pruning becomes essential. Alpha-beta maintains two values โ€” alpha (the best score the maximizer can guarantee) and beta (the best score the minimizer can guarantee). When the algorithm detects that a branch cannot possibly influence the final decision (because alpha โ‰ฅ beta), it "prunes" that branch entirely, avoiding unnecessary computation.

function alphaBeta(node, depth, alpha, beta, isMaximizing) {
  if (depth === 0 || isTerminal(node)) {
    return evaluate(node);
  }
  if (isMaximizing) {
    let value = -Infinity;
    for (let child of generateMoves(node)) {
      value = Math.max(value, alphaBeta(child, depth - 1, alpha, beta, false));
      alpha = Math.max(alpha, value);
      if (alpha >= beta) break; // Beta cutoff
    }
    return value;
  } else {
    let value = Infinity;
    for (let child of generateMoves(node)) {
      value = Math.min(value, alphaBeta(child, depth - 1, alpha, beta, true));
      beta = Math.min(beta, value);
      if (alpha >= beta) break; // Alpha cutoff
    }
    return value;
  }
}

With good move ordering, alpha-beta pruning can effectively reduce the branching factor from b to approximately โˆšb, effectively doubling the achievable search depth for the same computational budget. Modern Gomoku engines further enhance alpha-beta with techniques like iterative deepening (searching to increasing depths and using each iteration's results to improve move ordering), transposition tables (caching evaluations of previously seen positions), and null-move pruning (quick checks for positions so dominant that deep search is unnecessary).

4.2 Threat-Space Search

Threat-space search (TSS) is perhaps the single most important algorithmic contribution specific to Gomoku AI. Developed and refined by Victor Allis, Uiterwijk, and Van den Herik, TSS focuses exclusively on forcing moves โ€” moves that create a threat which the opponent must respond to immediately. This dramatically constrains the search space because at each step, the attacker has many possible threats to choose from, but the defender's responses are severely limited.

In Gomoku, a "threat" is typically a move that creates a configuration requiring an immediate block โ€” for instance, completing four stones in a row with an open end. The key insight of TSS is that many Gomoku positions can be resolved entirely through chains of threats, without ever considering non-forcing moves. If the attacker can construct a sequence of threats that leads to five in a row regardless of how the defender responds, the position is won.

โšก Why TSS Works So Well for Gomoku: Unlike chess, where there are many positional considerations beyond immediate tactics, Gomoku's winning condition (five in a row) is purely pattern-based. This means that forced tactical sequences โ€” threats and counter-threats โ€” dominate the game. TSS exploits this structure by ignoring the vast space of quiet, non-forcing moves and focusing only on the critical tactical lines.

TSS operates by building a tree of threat sequences. At each node, the attacker proposes a threat; the defender responds with the required blocking move; and the search continues. If the attacker can reach a winning configuration (e.g., creating two simultaneous unstoppable threats, known as a "double threat" or "fork") in every branch, the position is proven to be winning. If any branch allows the defender to escape all threats, the position may require a different approach.

This technique was the backbone of Allis's 1994 proof and remains central to the strongest Gomoku engines. It is especially powerful in the middle game, where tactical complications arise frequently and the ability to calculate forcing sequences accurately determines the outcome.

4.3 Monte Carlo Tree Search (MCTS)

Monte Carlo Tree Search revolutionized game AI when it emerged in the mid-2000s, initially for Go but quickly adopted for many other games including Gomoku. Unlike minimax, which systematically evaluates the game tree to a fixed depth, MCTS uses randomized simulations (called "rollouts" or "playouts") to estimate the value of positions.

The MCTS algorithm operates in four phases, repeated thousands or millions of times:

  1. Selection: Starting from the root, traverse the tree using a policy (typically UCB1 โ€” Upper Confidence Bound) that balances exploitation (visiting promising nodes) with exploration (visiting less-studied nodes).
  2. Expansion: When a leaf node is reached, expand the tree by adding one or more child nodes representing legal moves.
  3. Simulation: From the new node, play out the game to completion using a fast, typically random policy. This gives a rough estimate of the position's value.
  4. Backpropagation: Propagate the simulation result back up the tree, updating win/visit statistics at each node along the path.

MCTS has several advantages for Gomoku. It requires no hand-crafted evaluation function โ€” the simulations themselves provide the evaluation. It is anytime: it can be stopped at any point and immediately return the best move found so far. And it handles the large branching factor gracefully by focusing computational effort on the most promising regions of the game tree.

However, pure MCTS can struggle with sharp tactical positions in Gomoku where a single missed threat leads to an immediate loss. This is why the strongest modern engines combine MCTS with threat-space search or neural network evaluation (or both) rather than relying on random rollouts alone.

4.4 Pattern Matching & Evaluation Functions

Whether an engine uses minimax, MCTS, or a hybrid approach, it typically needs a way to evaluate non-terminal positions โ€” boards where neither player has yet won. In Gomoku, pattern-based evaluation is the dominant approach.

A Gomoku evaluation function scans the board for specific stone patterns and assigns each a score based on its tactical significance. Common patterns include:

The evaluation function typically sums scores for both players and returns the difference. More sophisticated functions also consider pattern combinations โ€” for instance, two open threes that share a common creating move (a "double-three fork") should be scored much higher than the sum of two individual open threes, because the resulting fork is essentially unstoppable.

To learn more about these fundamental patterns from a player's perspective, see our guides on Gomoku patterns and winning strategy.

๐Ÿ”ฌ Efficiency Tip โ€” Incremental Updates: Rather than re-scanning the entire board after each move, well-optimized engines use incremental evaluation, updating only the patterns affected by the most recent stone placement. This is typically implemented using directional pattern tables โ€” checking the four directions (horizontal, vertical, and both diagonals) through the newly placed stone to update the score in O(1) amortized time.

5. Neural Networks & Deep Learning for Gomoku

The success of DeepMind's AlphaGo (2016) and AlphaZero (2017) demonstrated that deep neural networks, combined with reinforcement learning and MCTS, could achieve superhuman performance in complex board games โ€” including ones where hand-crafted evaluation functions were thought to be essential. These breakthroughs quickly inspired researchers and hobbyists to apply similar techniques to Gomoku.

The AlphaZero Paradigm

The AlphaZero approach uses a single deep neural network that takes the board state as input and outputs two things simultaneously:

The network is trained through self-play reinforcement learning: the system plays millions of games against itself, using MCTS guided by the current network to select moves. The outcomes of these games are then used to improve the network (the policy is trained to match the MCTS-refined move probabilities, and the value head is trained to predict game outcomes). Over time, the network and the search procedure improve each other in a virtuous cycle.

For Gomoku, this approach works exceptionally well. The 15ร—15 board can be naturally represented as a grid input to a convolutional neural network (CNN), and the game's relatively short average length (compared to Go) means that self-play training converges quickly. Researchers have demonstrated that an AlphaZero-style system can learn to play Gomoku at a superhuman level starting from zero domain knowledge โ€” no pattern libraries, no opening books, and no hand-crafted evaluation functions.

Convolutional Architectures for Gomoku

Most neural network Gomoku engines use a residual convolutional architecture (ResNet), similar to the architecture used in AlphaZero. The board state is encoded as multiple feature planes โ€” for example, one plane for Black stones, one for White stones, and additional planes encoding move history or whose turn it is. These planes are processed through a series of residual blocks (convolutional layers with skip connections), producing a rich internal representation of the position.

The network then splits into two "heads": a policy head (producing move probabilities via a softmax over the 225 board positions) and a value head (producing a scalar win-probability estimate via a tanh activation). This dual-headed architecture is key to the method's success: the policy guides MCTS exploration toward promising moves, while the value estimate replaces random rollouts with a fast, learned evaluation.

๐Ÿ“Š Training Scale: A typical competitive Gomoku neural network might use 10โ€“20 residual blocks and be trained on 500,000 to several million self-play games. Training on a modern GPU takes days to weeks depending on the network size and desired strength. Despite this being a fraction of the resources DeepMind used for AlphaZero, the resulting Gomoku engines are extremely strong.

Advantages Over Classical Approaches

Neural network approaches offer several advantages over classical pattern-based engines. They can discover subtle positional concepts that are difficult to encode manually โ€” for instance, the long-term influence of stone configurations that do not constitute immediate threats but shape the flow of the game. They are also more adaptable: the same architecture can be applied to different board sizes or rule variants (such as Renju, as described in our Gomoku vs. Renju comparison) with minimal modification. Finally, because these networks learn from self-play rather than human games, they are not limited by the biases and blind spots of human strategy.

6. Gomoku AI vs Human Players

The history of Gomoku AI vs human competition is shorter but no less dramatic than the famous chess and Go matchups. Because Gomoku is a solved game, the fundamental question is not whether computers can beat humans โ€” they can, provably โ€” but how the dynamic between human and machine play has evolved.

Notable Milestones

By the mid-1990s, following Allis's proof, the strongest Gomoku programs were already competitive with top human players. The Computer Olympiad featured regular Gomoku tournaments where programs like Go-Moku (by Uiterwijk) and Carbon demonstrated increasingly dominant performance. In the 2000s, programs like Yixin (developed by Kai Sun) set new standards for engine strength, regularly claiming gold medals at the Computer Olympiad and performing impressively in human-vs-computer exhibition matches.

Unlike in chess, where the Kasparov vs. Deep Blue match in 1997 was a singular cultural moment, the ascendancy of Gomoku AI happened more gradually. This is partly because Gomoku's professional competitive scene is smaller than chess's, and partly because the game's "solved" status made human-vs-computer contests feel less like open questions and more like demonstrations of established superiority.

The Current State

Today, no human player can consistently defeat a top-level Gomoku engine in freestyle (unrestricted) Gomoku. The gap is substantial: engines calculate tactical sequences far deeper and more accurately than any human, and their positional understanding (especially in engines that use neural networks) rivals or exceeds the best human intuition. Under Renju rules, which impose restrictions on the first player to mitigate the first-player advantage, the competition is slightly more balanced โ€” but even here, the strongest engines dominate.

That said, watching how top human players perform against engines is instructive. Humans tend to excel at creative, non-obvious moves that lie outside an engine's primary search โ€” surprise moves that force the engine to recalculate. The best human players also demonstrate remarkable intuition for long-term positional play. However, these advantages are not enough to overcome the engine's tactical superiority in practical play.

7. How Modern Gomoku Engines Work

A state-of-the-art Gomoku engine in 2026 is a sophisticated piece of software that combines multiple algorithmic techniques into a unified system. Here is a high-level overview of how the strongest engines operate:

Architecture Overview

  1. Move Generation: The engine identifies candidate moves โ€” typically positions adjacent to existing stones, filtered by relevance heuristics. On a 15ร—15 board, this reduces the 200+ legal moves per position to perhaps 20โ€“40 candidates worthy of deep analysis.
  2. Search: The engine uses either alpha-beta search (with iterative deepening) or MCTS (possibly neural-network-guided) โ€” or increasingly, a hybrid combining both. The search explores the game tree from the current position, looking multiple moves ahead.
  3. Evaluation: Non-terminal positions are evaluated using either a pattern-based evaluation function, a neural network, or both. The evaluation assigns a score reflecting each side's winning chances.
  4. Threat Detection: A specialized threat-space search module handles tactical complications, looking for forced winning sequences. If a forcing win is found, the engine plays it immediately without further deliberation.
  5. Opening Book: Many engines include a precomputed database of standard openings and their evaluations, allowing them to play the early game instantly and accurately.
  6. Time Management: In timed games, the engine allocates search time based on the game phase and complexity of the position, spending more time on critical moments and less on straightforward positions.
๐Ÿ—๏ธ Hybrid is King: The trend in top Gomoku engines is toward hybrid architectures that combine the tactical precision of threat-space search and alpha-beta with the positional understanding and flexibility of neural-network-guided MCTS. This mirrors the broader trend in game AI โ€” the strongest engines are those that intelligently combine multiple paradigms rather than relying on any single technique.

Performance Characteristics

On modern hardware, a well-optimized Gomoku engine can evaluate millions of positions per second during alpha-beta search, or run tens of thousands of MCTS simulations per second. This is sufficient to search 15โ€“25 moves deep (much deeper along forced tactical lines) in just a few seconds, far exceeding what any human can calculate.

8. Open Source Gomoku AI Projects

One of the most exciting aspects of Gomoku AI is the vibrant open source community. Unlike many competitive AI domains where the strongest engines are proprietary, Gomoku has several excellent open source projects that allow anyone to study, modify, and build upon state-of-the-art techniques.

These projects make Gomoku an exceptional domain for learning about game AI. A motivated programmer can download an engine, study its source code, and even build a competitive program โ€” an educational journey that touches on search algorithms, evaluation functions, data structures, neural networks, and more.

9. What Gomoku Teaches Us About AI

Gomoku's story in AI is far more than a niche curiosity โ€” it illuminates fundamental principles about how machines think, plan, and learn. Here are the broader lessons that emerge from decades of Gomoku AI research:

The Power of Abstraction

Gomoku AI demonstrates that intelligent behavior can emerge from the interaction of simple components. Alpha-beta search is a generic algorithm; pattern evaluation is domain-specific knowledge; threat-space search is a tactical specialization. None of these components is intelligent in isolation. Together, they produce play that exceeds human capability. This compositionality is a central theme in AI: complex intelligence arises from the orchestration of specialized modules.

Search vs Knowledge

The history of Gomoku AI encapsulates the classic debate in AI between search (exploring possibilities) and knowledge (encoding what matters). Early programs relied heavily on search with minimal knowledge; engines like Allis's relied on deep domain knowledge (threat sequences) with targeted search; modern neural network engines learn their own knowledge from scratch and use search (MCTS) to apply it. The recurring lesson is that the combination of search and knowledge always outperforms either alone.

Solvability and Complexity

Gomoku occupies a fascinating middle ground in the landscape of game complexity. It is complex enough to resist trivial analysis โ€” its game tree is vastly larger than the number of atoms in the observable universe โ€” yet its structure is regular enough to permit mathematical solving. This teaches us that complexity alone does not determine difficulty; the structure of the problem matters enormously. Games with many forced sequences (like Gomoku) are more amenable to algorithmic analysis than games of comparable size but less tactical structure.

Learning Without Human Knowledge

AlphaZero-style approaches to Gomoku demonstrate something profound: a system can learn to play a game at an expert level without any human guidance. The network discovers opening theory, evaluates positional concepts, and develops tactical skills purely through self-play. This suggests that many forms of expert knowledge, which we once thought required human insight to encode, can instead emerge from sufficiently powerful learning systems given enough experience.

๐ŸŒ Beyond Games: The techniques developed for Gomoku AI โ€” tree search, pattern recognition, reinforcement learning, and neural evaluation โ€” have applications far beyond gaming. They inform research in logistics optimization, drug discovery, automated theorem proving, and any domain where decisions must be made by searching through large spaces of possibilities. Gomoku serves as an accessible proving ground for methods that ultimately shape the broader field of artificial intelligence.

10. The Future: AI as Training Partner

As Gomoku AI has progressed from research curiosity to superhuman capability, its most exciting application has shifted from competition to education and training. Rather than viewing engines as unbeatable opponents, the Gomoku community increasingly embraces them as powerful learning tools.

AI-Assisted Analysis

Modern Gomoku engines can analyze any position in seconds, identifying the best moves and explaining why they are strong through the threat sequences and evaluations that support them. Players can review their games with engine assistance, discovering where they missed tactical opportunities, where they made defensive errors, and where the critical turning points occurred. This is analogous to how chess players use Stockfish โ€” and it is just as transformative for improvement.

Adaptive Difficulty

One promising direction is AI opponents that adjust their playing strength to match the player's level. Rather than crushing beginners with perfect play, an adaptive engine deliberately presents positions that challenge the player at the edge of their ability โ€” creating learning opportunities without discouragement. This pedagogical approach, informed by research in intelligent tutoring systems, could dramatically accelerate how new players develop their skills.

Discovering New Strategies

Neural network engines sometimes discover novel strategic ideas that human players had not considered. By studying engine games and engine-recommended moves in unusual positions, top players can expand their understanding of the game's possibilities. In chess, this has already led to a renaissance of opening theory; similar effects are beginning to emerge in competitive Gomoku and Renju play.

Playing and Learning on Gomoku Five

Right here on Gomoku Five, you can play Gomoku online against human opponents from around the world. Whether you are a complete beginner learning the basic rules, an intermediate player working on your strategic fundamentals, or an advanced competitor refining your opening repertoire, playing against challenging opponents โ€” both human and AI โ€” is the fastest path to improvement.

The story of Gomoku and AI is ultimately a story about the partnership between human creativity and computational power. Machines solved the game, and machines can play it better than any human. But computers also give us tools to understand the game more deeply, to learn faster, and to appreciate the staggering richness hidden within twenty-five characters of rules. The future of Gomoku is not human versus machine โ€” it is human with machine, each making the other better.

Continue Your Gomoku Journey

Ready to Test Your Skills Against the World?

Play Gomoku online for free. Challenge opponents from across the globe โ€” from beginner to expert โ€” and put your knowledge of strategy and AI insights into practice.

โ–ถ Play Gomoku Now