Introduction

Gomoku, or five-in-a-row, has the gentlest rules imaginable. Two players take turns dropping stones on the lines of a grid — one black, one white — and the first to line up five stones in a row, horizontally, vertically or diagonally, wins. Children learn it in minutes; you can play it on graph paper with a friend.

It feels perfectly fair. Both players want the same thing, the board is symmetric, and surely whoever plays better wins. But "perfectly fair" turns out to be wrong. On the standard 15x15 board with no opening restrictions, the player who moves first holds a decisive advantage — one strong enough to guarantee victory against any defense.

The reason is a single idea you can feel in your own hands: the double threat, a move that makes two winning lines at once. Your opponent can block only one of them.

Build the Double Threat

You are black and you move first. The engine plays white and defends as best it can. Your goal is not just five in a row — it is to reach a position with two threats at once, so that wherever white blocks, the other threat still completes your five.

<p class="hint">{{hint_intro}}</p>
<div id="board" class="board"></div>
<div class="status" id="status">{{your_move}}</div>
<div class="btns">
  <button id="hint" type="button">{{btn_hint}}</button>
  <button id="reset" type="button" class="ghost">{{btn_new_game}}</button>
</div>
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; color: #222; margin: 0; }
.hint { font-size: .9rem; color: #444; margin: 0 0 .7rem; line-height: 1.45; }
.board { display: grid; grid-template-columns: repeat(9, 34px); gap: 0;
         background: #e7c993; border: 2px solid #b9924f; width: max-content;
         padding: 4px; border-radius: 6px; margin: .4rem 0; }
.pt { width: 34px; height: 34px; position: relative; cursor: pointer; }
.pt::before, .pt::after { content: ""; position: absolute; background: #9c7a3c; }
.pt::before { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-.5px); }
.pt::after { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-.5px); }
.stone { position: absolute; inset: 4px; border-radius: 50%; z-index: 2; }
.stone.b { background: radial-gradient(circle at 35% 30%, #555, #000); }
.stone.w { background: radial-gradient(circle at 35% 30%, #fff, #c2c2c2); border: 1px solid #999; }
.pt.win .stone { box-shadow: 0 0 0 3px #e63946; }
.pt.tip::after, .pt.tip::before { background: #137a3a; }
.pt.tip { outline: 2px dashed #137a3a; outline-offset: -3px; }
.status { font-size: 1rem; font-weight: 600; margin: .5rem 0; min-height: 1.4em; }
.status.ok { color: #0a7d33; }
.status.bad { color: #c92f3c; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; }
button { font: 600 14px system-ui, sans-serif; padding: .45rem .9rem; border: 1px solid #1d3557;
         background: #1d3557; color: #fff; border-radius: 8px; cursor: pointer; }
button.ghost { background: #fff; color: #1d3557; }
// Code not found

Watch what happens. White can always answer a single threat — a row of four with an open end. But the moment you place a stone that opens two fours simultaneously, white has only one move and two fires to put out. That fork is the whole secret: the first player, given enough room, can always manufacture one. Press Hint to see the engine point at a forking square.

The Real Complexity

So who wins Gomoku, really? For the free-style game this is no longer a mystery.

  • It is solved. In 1993, Victor Allis (with H. J. van den Herik and M. P. H. Huntjens) proved that on the 15x15 board with no opening restrictions, the first player wins with perfect play. Gomoku is one of the few real games whose outcome is settled.
  • The proof was a search, not a formula. Allis introduced threat-space search and proof-number search — methods that chase forced sequences of threats — and used them to exhaustively confirm a winning line for the first player.
  • It is an m,n,k-game. Gomoku is the (15, 15, 5) member of a whole family: an m×n board where you need k in a row. The strategy-stealing argument already shows the second player can never have a winning strategy in such games; Allis showed the first player actually does.
  • Generalized, it is hard. Decide the winner of an arbitrary m,n,k position on a board that grows with the input and the problem becomes PSPACE-complete — the same wall that blocks games like chess and Go from any quick general solution.

That is why competitive Gomoku adds opening rules (Swap, Renju restrictions): without them, the first player's forced win makes the game one-sided. The double threat you built in the demo is exactly the engine of that proof.

Where It Matters

"Force a win through a chain of threats the opponent cannot answer" is a pattern that runs through far more than five-in-a-row:

  • Game-playing AI: threat-space and proof-number search, sharpened on Gomoku, became standard tools for solving and playing two-player games.
  • Automated reasoning: proving a position is won is structurally like proving a theorem — both search a tree for a forced, unanswerable line.
  • Adversarial planning: security, scheduling and pursuit problems often reduce to "can I create two threats my adversary can only half-cover?"
  • Teaching strategy: the fork is the clearest possible lesson in why moving first, and creating dilemmas, beats reacting move by move.

Understand the double threat in Gomoku and you have met the heart of adversarial search — the same engine behind chess programs and the broader question of P vs NP.

Conclusion

Gomoku hides a clean surprise: a game simple enough for a child is also solved. On the free 15x15 board the first player can force a win, and the lever is the double threat — a move that opens two winning lines so the defender, with a single reply, can never seal both.

So the next time five-in-a-row feels like a fair coin flip, remember what Allis proved in 1993: with perfect play it is not a coin flip at all. The first stone, played well, already decides the game — and the same threat-chasing search that settled Gomoku still powers the way machines reason about chess and beyond.

Share this article

Pick a channel — or use your device's native share sheet.

Comments

Loading comments...

https://www.kipuhub.com/en/article/gomoku/Content licensed under CC BY-NC 4.0.