Skip to the board
BARRELHEAD

Gomoku

Your move.

You play red and go first. Put a piece where two lines cross. Five in a row wins, in any direction.

How to play

Pieces placedYour pieces:0The computer's pieces:0

Game
Opponent
Start over?

Fifteen lines each way, five in a row

Gomoku, the game also called five in a row, on a board painted on the head of a barrel.

The board and the pieces

Fifteen lines across and fifteen down. They cross in 225 points, and the pieces go on the points, not in the squares between the lines. Five points have a red dot: the middle of the board and four points around it. The dots help the eye find its place and have no part in the rules.

Small red and white pieces. The game is played with black and white stones where it comes from. Here the two sides are the red and white of every other board on this site. You play red and the computer plays white, unless you swap the colors under Settings.

The board starts empty. By tradition the dark side moves first. Here the first move is yours, unless you give it to the computer under Settings. Your color and the first move are separate choices there.

A move

The two sides take turns putting one piece on an empty point. Any empty point will do, anywhere on the board.

A piece stays where it is put. Nothing is moved and nothing is taken off the board during a game. You cannot pass.

Five in a row

The first side to get five of its pieces in an unbroken row wins. The row can run across, down, or diagonally, and it can lie anywhere on the board.

Unbroken means next to each other along one line. Five pieces with an empty point or a piece of the other color among them are not a row.

Two games: five or more, and exactly five

Five or more. This is the free game, and the one this board starts with. A row of five wins, and so does a row of six or more.

Exactly five. In the other game a row has to be five long and no longer. Six or more in a row is called an overline, and it does not win. Making one is allowed, and the game simply goes on. The same piece still wins if it makes a row of exactly five in another direction.

You choose under Game. Each of the two has its own saved game and its own record, so switching leaves the other one where it was.

How a game ends

Five in a row ends the game at once. On this board the winning row gets a chalk loop around it before the pieces are cleared away.

A full board with no winning row is a draw. That takes 225 pieces, and it almost never happens.

What is not played here

No forbidden moves. Renju, the tournament game built on gomoku, forbids the side that moves first to make two open threes, two fours or an overline with one piece. None of that applies here. Both sides may play any empty point.

No opening rules. Tournaments also use rules for the first few pieces, such as letting one player place the opening and the other choose a color. Here a game starts on an empty board with one piece.

Sources

Checked against the rules in the Wikipedia article on gomoku and in Victor Allis's thesis, named under How the computer plays here, where the two games are called free-style go-moku and standard go-moku, and against the engine that runs this board.

Questions people ask

Is gomoku the same as five in a row?

Yes. Gomoku is the Japanese name, short for gomokunarabe, and five in a row is what the game is. It has local names in many places: wuziqi in China, omok in Korea, gobang in older English books, and luffarschack in Sweden.

Do the pieces go on the lines or in the squares?

On the points where two lines cross, as in go, which is where the board and the stones come from. On squared paper the same game is played with marks inside the squares. Nothing else is different.

Does six in a row win?

That depends on the game you chose. With "Five or more" it does. With "Exactly five" it does not: the row counts for nothing, the board tells you so, and the game goes on.

What is an open three?

Three pieces in a row with the points at both ends empty, and room beyond them. One more piece at either end makes four in a row that is still open at both ends, and that cannot be stopped.

So an open three has to be answered on the very next move. It is the row a newcomer most often leaves alone, and then loses to.

Part of the board. Three red pieces lie in a row, and the empty points at both ends of the row have chalk rings around them. Three white pieces lie nearby.
An open three. A red piece on either point with a ring makes an open four.

What is an open four?

Four pieces in a row with the points at both ends empty. There are two ways to make five, and a single piece can only take one of them. An open four wins.

A four with one end closed is a different matter. It has one way to become five, and a piece on that point stops it.

Part of the board. Four red pieces lie in a row, and the empty points at both ends of the row have chalk rings around them. Four white pieces lie nearby.
An open four. Red makes five on either point with a ring, and white can only fill one.

Who wins if nobody makes a mistake?

The side that moves first. In 1993 Victor Allis showed that in the free game, on a board of fifteen lines each way and with no restrictions on the opening, the first player can force a win. His program searched for chains of threats, each of which has to be answered, and found a win against every defense.

This is why tournament play adds forbidden moves or opening rules: without them the first move is worth too much. This board has none, so going first is a real advantage. You can give it to the computer under Settings.

Where should the first piece go?

In the middle. A piece there can grow into a row in every direction, with seven points of room each way. The computer starts in the middle, or right next to it when it varies its opening.

Can a game end in a draw?

Only if the whole board fills up. That is 225 pieces without a winning row, and in practice somebody wins long before.

Why does the board come closer when I tap it?

Because 225 points are too many for a fingertip on a phone. There the first tap brings the board closer around the place you touched, and the second tap puts the piece down. A single tap never places a piece on a phone, so a stray touch costs nothing.

A tap below the board shows the whole board again. On a screen where the points are far enough apart, or with a mouse, a move is a single click.

Are the two games kept apart?

Yes. "Five or more" and "Exactly five" each have a saved game and a record of their own. Switching under Game leaves the other game where it was, and it is still there when you switch back.

Is this the same as renju or go?

No. Go uses the same kind of board and stones, but it is a game about surrounding territory, and stones are captured. Renju is gomoku with forbidden moves for the side that starts. This page has neither.

How games are won

Know which rows have to be answered

Two kinds of row cannot be left alone. A four, because the next piece makes five. And an open three, because the next piece makes an open four, which is already won.

Before every move, look for both, yours and the computer's. If the computer has one, your move is decided: stop it, unless you can make five yourself.

Win with two threats at once

Nobody leaves a four unanswered on purpose. Games are won by a piece that makes two threats with one move, so that answering one leaves the other.

  • A four and an open three: the four has to be blocked, and then the three becomes an open four.
  • Two open threes: only one can be stopped, unless the other side has a four of its own to play first.
  • Two fours: two points make five, and one piece cannot take both.

The point to look for is the one where two of your rows cross.

A row with a gap counts

Two pieces, an empty point and one more piece on the same line are a three: fill the gap and it is four in a row. Three pieces, a gap and one more are a four: fill the gap and it is five.

Rows like these are easy to overlook, for people and for the lower levels here. Beginner and Easy see only unbroken rows.

Keep the move

A threat that has to be answered also decides where the other side plays. A player who makes one such threat after another places every piece where it suits, while the other side only follows.

A four is the strongest of them: there is exactly one answer. Strong players win by a chain of fours and open threes that ends in two threats at once. The same holds in defense. When you have to block, block with a piece that also builds a row of your own.

Block the right end

An open three can be stopped at either end. Pick the end where your piece does more: where it lies in line with other pieces of yours, or where it sits on a point the computer needs for a second row.

Stay near the middle

A row needs five points on a line. Near the edge of the board there are fewer of them, and a row that runs into the edge is closed at that end. Pieces in the middle have room in all directions.

In the exactly-five game, six is a defense

When only exactly five wins, a row that would grow to six is no threat at that end. Four in a row with one more piece of the same color a step beyond the empty point cannot be finished there: the piece that fills the gap makes six.

It works both ways. Check that your own four really has a point where it becomes five and not six.

Use the hint as a second opinion

The Hint button asks the engine at full strength what it would play. When its point is not the one you had in mind, look for the row it stops or the two rows it joins before you play either.

How the computer plays here

Five levels, one engine. The lower levels see less of what is on the board. The top level looks for a win that can be forced.

How it thinks

For every empty point the engine keeps track of what a piece there would make, for each side and along each of the four lines through the point: a five, an open four, a four, an open three, and so on down to a lone piece. A three with a gap in it is found the same way as an unbroken one.

Its moves come from those threats. If it can make five, it does. If you can, it blocks. If you have an open three, it tries only the points that stop it, or a four of its own. Otherwise it tries the empty points within two steps of a piece, the most threatening first, then your answers and its answers to those, as many moves deep as the level allows.

The two strongest levels also run a search of their own for forced wins: rows of fours, or of fours and open threes, where every move has to be answered. A win found that way is certain, because the answers it considers are the only ones there are.

All of this happens on your own device, in your browser.

Beginner

Looks at its own move only, with a beginner's eye: it sees unbroken rows and nothing else, and no double threats. It blocks an unbroken four and an unbroken open three. In every other move it only glances at the board, and then it misses the three.

Easy

Has the same eye, but looks at your answer as well and builds on its own rows with a purpose. It is careless in about one move out of five, and it never sees a four with a gap in it.

Medium

Sees what is really there: rows with gaps, and double threats once they are on the board. It still looks only two moves ahead, so it does not see them coming. It is careless in about one move out of twelve.

Hard

Looks four moves ahead and is never careless. It also searches for short forced wins, four threats long.

Expert

Gets one second for every move in place of a fixed depth, and searches for forced wins ten threats long. On the computer where it was measured it used 0.4 seconds a move on average and looked seven moves ahead. It varies its first few pieces a little, so that games do not all begin the same way.

The levels against each other

Each level has played the level below it in the free game. The games began from random openings of one to four pieces near the middle. Every opening was played twice, so that both levels got to start from it, and in every other opening white placed first. No game was drawn.

  • Easy against Beginner: 902 wins and 98 losses, over 1,000 games.
  • Medium against Easy: 867 wins and 133 losses, over 1,000 games.
  • Hard against Medium: 365 wins and 35 losses, over 400 games.
  • Expert against Hard: 34 wins and 6 losses, over 40 games.

With the exactly-five rule, Medium beat Easy 348 times in 400 games. The other steps were measured in the free game only.

The last figure rests on few games, because Expert uses its clock. And all of these are engines playing engines: a simple model of an ordinary beginner, one that makes its longest row longer and blocks only fours, beat Beginner in 658 games out of 1,000.

What Expert does not know

The proof that the first player wins was found by a program built for that one task. Expert has one second a move and no book of openings. It does not know the winning line, and it does not play without error: it lost six of its forty games against Hard.

So the proven result does not decide games on this board. Going first is an advantage, against Expert as against anyone, and Expert can be beaten from either side.

What the hint is

The Hint button is the engine at full strength: one second, and the search for forced wins ten threats long. That is Expert without the variety in its opening.

Using it does not make the level you are playing any stronger: every search starts from nothing. Hints are counted, and the count is shown with your record at the bottom of the page.

Sources

The result for the game with no opening restrictions is from L. V. Allis, H. J. van den Herik and M. P. H. Huntjens, "Go-Moku Solved by New Search Techniques" (1993), and from Allis's thesis "Searching for Solutions in Games and Artificial Intelligence" (University of Limburg, 1994).

The other barrels

Checkers is the one where a jump has to be taken, and where a piece that reaches the far row becomes a king, two pieces high.

Backgammon is a race with dice: fifteen pieces a side, and a piece left on its own can be hit and sent back to the start.

Shut the Box is nine numbered tiles and two dice: every roll has to be paid for with tiles that add up to it, and the lower sum left open wins.

Farkle is six dice and a race to 10,000: bank what a turn is worth, or roll again and risk losing all of it.

Yatzy is five dice and a scorecard of thirteen rows: three rolls a turn, and every turn has to be written in a row, even when it is worth nothing there.

Dominoes is twenty-eight tiles and a line that grows at both ends: match a number, draw from the boneyard when nothing fits, and lay your last tile first.

Reversi has one kind of move: put a piece down so that it traps a row of the other color, and the row turns to yours.

Mancala has no dice and nothing hidden: you empty a pit, sow its stones round the board one at a time, and count what ends up in your store.

Chinese Checkers is a race across a star of 121 holes: marbles hop over one another in chains, nothing is ever captured, and the first side to fill the point opposite wins.

Nine Men's Morris is the old game of mills: nine pieces a side, three in a row along a line takes a piece off, and a side left with two pieces or no move has lost.

Tic-Tac-Toe is three in a row on nine squares, and next to it Ultimate tic-tac-toe, where every square holds a small board and each move decides where the next one is played.

Four in a Row is the standing rack laid flat: seven lanes of six places, a piece slides down its lane until it is stopped, and the first side with four in a row wins.

Chess is the old game of kings: six kinds of pieces that each move their own way, and a win when the other king is attacked and cannot escape.

Ludo is the race with one die: a six brings a piece out of its yard, landing on another color sends that piece back, and the first side with all four pieces home wins.

Five or more wins

No games played yet.

Red for the games you won, white for the ones you lost. The two games are counted apart, and this is the record of the one on the board. It is kept in this browser and nowhere else.

Start over?