Five in a Row

Take turns placing stones on the grid. The first to line up five of their own — across, down or diagonally — wins, and the computer is trying to do exactly the same thing to you.

How to play

You play black and move first, dropping a stone on any empty point.

  1. Place a stone Click any empty point on the board.
  2. Build towards five Across, down or diagonally all count.
  3. Block their lines A row of three with space at both ends will become an unstoppable four.
Full instructions

In depth

Winning at five in a row against a stone-counting computer

How the board works, what an open three really means, why the middle matters more than the edge, and the two-threat trick that ends games before the computer can stop you.

Screenshot: How to play Five in a Row
How to play Five in a Row as it appears when the page opens.

The goal in one sentence

You and the computer take turns placing stones on a 13 by 13 grid. You are black and go first. The first side to form an unbroken line of five stones wins. The line can run across, down, or on either diagonal. That is the entire rule set.

If every square fills up before either side reaches five, the game is a draw. In practice that almost never happens. Games end long before the board is full, because a line of five only needs a fraction of the 169 squares.

Placing a stone and reading the board

Click or tap any empty intersection. Your stone appears in its colour and the computer answers within a moment. The scoreboard tracks two things: how many moves you have made, and the length of your longest current line.

That second number is worth watching. It tells you how close you are to winning without counting on your fingers. If it reads four and it is your turn, the game is over. If it reads three, look at which ends of that line are open before you get excited.

What makes an open three dangerous

A row of three stones with an empty point at each end is called an open three. Next turn it becomes a four that the opponent cannot block on both sides. One end gets plugged and the other end still scores. This is the single most important shape in the game.

A blocked three, by contrast, has a stone or a board edge closing one end. It can be stopped with a single move and is not nearly as threatening. The difference between an open and a blocked three decides most games. Build open threes wherever you can. Block the ones you see forming against you, before they grow.

Here is a concrete situation. Suppose you have stones at row 7 columns 4, 5 and 6, and both column 3 and column 7 are empty. That is an open three. Place a stone at column 3 or column 7 and you have an open four. The computer will fill one end, but you complete the line at the other.

Now imagine the same three stones but with column 3 already occupied by the computer. That three is blocked on one end. The computer places its stone at column 7 and your line is dead. You wasted three moves building something that was never going to work. Before you extend a line, always check both ends.

The double-threat move

A single open three gets blocked. But a move that creates two open threes at the same time cannot be answered, because the computer only gets one turn. This is the strongest tactic available to you.

Picture an L shape on the board. You place a stone at the corner of the L and it completes a horizontal three and a diagonal three at the same time. Both are open. The computer blocks one; you finish the other. Game over.

Setting up a double threat takes planning. You need two lines that share a gap, and you need both lines to have open ends once that gap is filled. It usually takes three or four moves of quiet building before the final stone drops into place.

Why the centre is worth more than the edge

A stone near the middle of the board belongs to more possible five-in-a-row lines than one pressed against the side. Count it yourself. A stone in the exact centre can be part of lines running in four directions, each with room to grow. A stone in the corner can only extend in three directions at most, and each of those hits a wall quickly.

The computer knows this. Its scoring adds a small bonus for central positions. If you open near the middle and keep your early stones within a few squares of each other, you give yourself the most room to build threats.

How the computer decides where to play

It does not search deeply the way a chess engine does. Instead it looks at every empty square near the existing stones, scores each one for both sides, and picks the best. It checks for an immediate win first. If it can complete five, it does. Then it checks whether you can complete five on your next turn, and blocks that.

After those two checks it falls back to its scoring system. Each candidate square gets points for how long a line it would extend, and how many ends of that line are open. An open four scores enormously. An open three scores well. A blocked pair scores little.

On Easy difficulty the computer picks randomly from its top five candidates, so it makes visible mistakes. On Normal it takes the best move most of the time. On Hard it also weighs your threats almost as heavily as its own, which means it blocks earlier and builds less greedily.

Playing the three difficulty levels

Easy is where you learn the rhythm. The computer misses open threes and sometimes ignores a four it should block. Use these games to practise building double threats without pressure.

Normal is a fair fight. The computer blocks most threats and builds its own lines efficiently. You need to think two moves ahead, not just one. Place a stone and ask yourself what it creates after the computer responds.

Hard punishes loose play. The computer values your shapes almost as highly as its own, so it blocks early and rarely lets an open three survive. Winning here means setting traps over three or four moves so the final threat arrives from a direction the computer did not expect. You will need to build in two areas of the board at once and force the computer to choose which one to defend.

Common mistakes new players make

Chasing length instead of openness is the most common error. A blocked four is less dangerous than an open three, because the blocked four can be stopped in one move. Always count the open ends before counting the stones in a line.

  • Building along the edge. A line against the wall has one end already sealed, so it can never become an open threat.
  • Ignoring the computer's three. If it has three in a row with both ends open, you must plug one end right now. Waiting one turn means it becomes four, and then it is too late.
  • Spreading stones too far apart. Five in a row means the stones must be neighbours. Two pairs with a gap between them are two weak shapes, not one strong one.
  • Forgetting the diagonals. New players watch rows and columns but miss a diagonal line growing behind their stones. The computer checks all four directions every turn.

A worked opening sequence

Start near the centre. Place your first stone around row 7 column 7. The computer answers somewhere nearby. Place your second stone next to your first, forming a pair in a direction that has open space on both sides.

The computer blocks or builds. Either way, place your third stone so it extends your pair into a three with two open ends if you can. If the computer has blocked that line, start a second line close enough that a future stone could threaten both at once.

By move four or five, look for the square that creates two open threes at the same time. If it exists, take it. If not, keep building quietly. Patience wins this game more often than aggression.

Do not worry if the computer seems to be building faster at first. It always answers a direct threat before pursuing its own plans. If you can keep it busy blocking, it never gets ahead. The opening is about creating structure, not about rushing to three.

Everything stays on your device

The board, the computer's logic, and your best score all live inside this page on your own machine. Nothing is sent to a server. There is no account, no login, and no data stored anywhere except your browser. Close the tab and everything is gone except the best score, which sits in local storage until you clear it.

You can prove this by loading the page and then disconnecting from the internet. The game still works exactly as before, because there was never a server involved in playing it.

Help

How to play Five in a Row

You play black and move first, dropping a stone on any empty point. Nothing is captured or moved afterwards, so every stone is a permanent commitment, and an open four made by either side settles the game a move before it ends. Watching what the computer is quietly building matters as much as building your own line.

Place a stone

Click any empty point on the board.

Build towards five

Across, down or diagonally all count.

Block their lines

A row of three with space at both ends will become an unstoppable four.

Watch your longest line

The scoreboard shows how long your best run currently is.

Win before they do

You move first, which is a real advantage.

Runs on your device

The whole game is played inside this page. Nothing is uploaded, there is no account, and your best score is stored in this browser only. Once the page has loaded it works offline.

Good to know

An open three is the real threat

Three in a row with an empty point at each end becomes a four that cannot be blocked on both sides. Make them, and block theirs immediately.

Build two threats at once

A single line gets blocked. A move that creates two threes at the same time cannot be answered.

The computer blocks before it builds

It checks for an immediate win and an immediate block before it considers anything else, so hoping it misses a four will not work.

Play near the middle

A stone in the centre belongs to far more possible lines than one at the edge.

Common questions

What counts as a win?
Five of your stones in an unbroken line, in any direction.
Why did it block that?
It looks for your threats before its own plans. Any three of yours with room to grow will be answered.
Is going first an advantage?
Yes, a significant one in this game, which is why you get it.
Is it free?
Yes — no account, no limit on how many games you play, and no ads inside the game area itself. Ads on the page around it pay for the site.
Does it work on a phone?
Yes. The board scales to your screen and the controls are made big enough to use with a thumb.
Where is my best score kept?
In your browser on this device. It is never sent anywhere and will not follow you to another computer.