Play Gomoku (Five in a Row) online

Get five stones in a row on a 15 by 15 or 19 by 19 board. Play the computer on Easy, Medium or Hard, or take turns with a friend on one screen.

How it works

  1. Pick vs Computer or 2 players, a level, the board size and the rule in the menu
  2. Tap an intersection to place a stone (tap twice on a phone to confirm), or use the arrow keys and Enter
  3. Line up five stones in a row, column or diagonal before your opponent does

How to win at Gomoku

To win at Gomoku, place five of your stones in an unbroken straight line, across, up and down, or diagonally, before your opponent does. Players take turns putting one stone on an empty intersection of the grid, and black always moves first. Stones never move and are never captured. The usual board is 15 by 15, which gives 225 points; a 19 by 19 board, the size of a Go board, gives 361 and is also offered here. This page has two rules. In Freestyle, five or more stones in a row win, so a line of six counts. In Standard, only exactly five wins, and a longer line, called an overline, does not win for either side. If every point is filled and nobody has five, the game is a draw. The last stone placed is marked with a small teal dot, and the winning line is highlighted with a bright ring. White stones have a dark ring, so the two colours can be told apart without relying on colour. Undo takes back your last stone; against the computer it also takes back the computer's reply. This page does not apply the Renju restrictions that forbid black from some double threes and double fours.

How the computer plays

The computer scores the whole board by looking at every group of 5 neighbouring points in a row, column or diagonal. A group that holds only one side's stones is worth more the more stones it holds: 1, 12, 150 and 2000 points for one to four stones. An open three sits inside three such groups and a closed three inside one, so open threats count about three times as much, which is the reason open threes and open fours are the shapes that win games. It then searches ahead with negamax and alpha-beta pruning, looking only at the best few moves near existing stones, and stops when it has examined a fixed number of positions. Easy looks 2 moves ahead and 35 times in 100 plays a plain nearby move without checking your threats. Medium looks 3 moves ahead. Hard looks 4 moves ahead and so sees that an open three left alone becomes an open four, which cannot be stopped. All levels take a win in one move; Medium and Hard also block a four every time. The first stone in a game goes in the centre. Nothing is sent to a server and the search runs in your browser in well under a second.

Strategy that works

Black has a large advantage in freestyle Gomoku with perfect play, which is why Renju and other rule sets restrict black. Against people and against this computer, play near the centre first, because stones there belong to more possible lines. Learn three shapes. A four with one open end forces an immediate reply. An open three, three stones with both ends open, threatens to become an open four, which wins because only one end can be blocked, so you must answer it at once. A double threat, such as a four and an open three made by the same stone, wins the game. Build threats that overlap, so one stone adds to two lines, and always check before each move for your opponent's open threes. On the Standard rule, a stone that makes six in a row does not win, so leave a gap if a line could run long.

Controls, saving and limits

With a mouse, click an intersection to place a stone. On a phone the board is small, so the option Tap twice to place is on by default below 860 pixels wide: the first tap shows a marker, the second tap places the stone. You can switch this in the menu. With a keyboard, Tab to the board, move with the arrow keys, Home and End, and press Enter or Space to place. The menu holds the mode, the level, who starts, the board size and the rule. A game in progress is saved in this browser after every move, and your wins against each level are kept there too. Two-player games are not counted. The page has no online play, no accounts, no time clock and no hints. Changing the board size or the rule starts a new game.

Frequently asked questions

How do you win at Gomoku?

Get five of your stones in an unbroken line, across, up and down, or diagonally, before your opponent. On the Freestyle rule 5 or more win; on the Standard rule only exactly 5 wins. If all 225 points of the 15 by 15 board fill with no five, it is a draw.

What is the difference between Freestyle and Standard?

In Freestyle a line of six or more also wins. In Standard only exactly five wins, and an overline of six or more does not count for either player. Choose Standard if you play by those rules in a club or an app.

Does black win by moving first?

With perfect play on a free 15 by 15 board, yes, black wins. That is why Renju bans some black moves. This page does not, so as white against the computer on Hard you will usually be defending. The menu lets you start as black or hand the first move to the computer.

How strong is the computer on each level?

Easy searches 2 moves ahead and plays a plain move in 35 of 100 turns, so it can miss a threat. Medium searches 3 moves ahead and Hard 4. Hard sees an open three turn into an open four and blocks it. Every level takes a win in one move.

How do I place a stone on a small phone screen?

On screens narrower than 860 pixels the first tap on a point marks it and a second tap on the same point places the stone, so a mis-tap on a 15 by 15 board costs nothing. Turn Tap twice to place off in the menu if you prefer single taps.

Are my games uploaded anywhere?

No. The computer's search runs in your browser. The game in progress, your settings and your win record per level are saved in this browser's storage only. The page counts visits with Google Analytics, never your moves.