Hex

On a diamond of hexagons, two sides belong to you and two to the computer. Claim cells in turn and try to complete an unbroken chain between your own sides first. The board cannot fill up without somebody having done it, so a draw is impossible.

How to play

Your two edges are the left and the right; the computer is working top to bottom across the same cells you want.

  1. Tap any empty cell Stones never move once placed.
  2. Build left to right Your two edges are the left and the right.
  3. Block their chain Blocking them and building yourself are the same move.
Full instructions
You: left to right Computer: top to bottom

In depth

Winning at Hex against the computer

How Hex works, why draws are impossible, what the computer is actually doing when it thinks, and the shapes and habits that will help you build a winning chain on any board size.

Screenshot: How to play Hex
How to play Hex as it appears when the page opens.

A game with no draws

Hex is played on a grid of hexagonal cells. You and the computer take turns placing a stone on any empty cell. Stones never move once placed. You are trying to build an unbroken chain of your own stones from the left edge of the board to the right edge. The computer is trying to join the top edge to the bottom.

The remarkable property of Hex is that a draw is impossible. When every cell on the board is filled, exactly one player will have a winning chain. This is a proven fact about the geometry of the board, not a rule imposed by the game. It means every game must produce a winner.

Board sizes and difficulty

Three settings are available. Easy plays on a seven-by-seven grid, Normal on nine-by-nine, and Hard on eleven-by-eleven. The board size and the computer's thinking power both increase together.

A smaller board is faster but less forgiving. On a seven-by-seven grid, one bad move can cost you the game because there are fewer cells to recover with. On an eleven-by-eleven grid you have more room to manoeuvre, but the computer also thinks harder and is more likely to find good moves.

The scoreboard shows how far across the board your longest chain has reached, as a percentage. It also tracks how many stones you have placed and whose turn it is.

How to play

Tap any empty cell to place your stone. The cell turns blue. The computer then places a red stone and it becomes your turn again. You go first, which is an advantage.

Your two edges are marked on the board: left and right for you, top and bottom for the computer. A legend below the board confirms this with coloured indicators. The goal is to connect your two edges with a continuous path of touching stones. Cells touch along all six sides of each hexagon, so a chain can go in any direction as long as each stone shares an edge with the next.

What the computer is doing

The computer uses a method called random playouts. For each cell it could play, it imagines filling the rest of the board at random, thousands of times, and counts how often it wins. It then plays the cell that won the most imaginary games.

This sounds crude, but it works well for Hex. Because the game has no draws, randomly filling a board always produces a winner. A move that wins in most random finishes is usually a move that helps in real play too. The computer checks for immediate wins and blocks before it bothers with playouts, so it never misses a finishing move or lets you win for free.

On the Hard setting the computer runs seven thousand playouts per move. On Easy it runs two thousand. The difference is noticeable. Hard play is slower but much more dangerous.

The bridge: the most important shape

Two of your stones that sit a knight's move apart, with two empty cells between them, form a bridge. A bridge is safe because your opponent cannot cut it. If they take one of the two empty cells, you take the other, and the connection is complete either way.

Bridges are better than solid lines of touching stones. A solid line uses more stones to cover the same distance. A bridge skips ahead and leaves the connecting cell for later, so you cover more ground per turn.

Look for chances to extend your chain with bridges rather than straight connections. The opponent has to respond to each bridge but can only block one of the two cells. This forces them to react instead of building their own chain.

Why the centre matters

A stone in the middle of the board belongs to far more possible paths than a stone on the edge. An edge stone can only connect in three or four directions. A centre stone connects in six. This makes centre cells more flexible and more valuable.

A strong opening move is often near the centre of the board. It does not commit you to a single path and it threatens connections in every direction. The computer knows this too, so expect it to contest the centre.

Edge cells are not useless, but they should serve a purpose. Playing on the edge makes sense when you are one stone away from connecting to your side, or when you need to block the computer from reaching its edge. Playing on the edge in the opening is usually a wasted turn.

Attack and defence are the same thing

Because Hex has no draws, every move that stops the computer from connecting also brings you closer to connecting yourself. There is no such thing as a purely defensive move. If you block the computer's path through the middle of the board, you have also placed a stone that might belong to your own chain later.

This means you should never play a move that only blocks. If you must block, choose the cell that also helps your own chain. When two cells both serve as a block, pick the one that sits closer to the path you are building. If you find yourself making moves that do nothing for your own chain, you are falling behind.

Going first is a real advantage

Hex is a first-player win with perfect play on any board size. This was proved by a strategy-stealing argument. If the second player had a winning method, the first player could steal it by making one extra move, which can never hurt, and then following the second player's strategy. That leads to a contradiction, so the first player must be the one with the advantage.

You always go first in this version. That means a loss is always a mistake somewhere on your part, not bad luck or an unfair setup. The computer can still win because it plays well, but it starts at a theoretical disadvantage.

Keeping two paths alive

The strongest position is one where your chain has two separate ways to finish. If the computer blocks one route, you complete the other. If it blocks neither, you pick whichever is shorter.

You build this by placing stones that threaten connections in more than one direction. A stone in the middle of the board might link to your existing chain from the left and also start a new path off to the right. The computer can only answer one of those per turn.

When your chain forks into two paths and both are a few moves from the edge, the game is over. The computer cannot block both, and you finish on whichever side it leaves open. Most wins are set up this way, not by a single unbroken line running straight across the board.

Reading the reach percentage

The scoreboard shows your reach as a percentage. This measures how far your longest connected chain extends from your starting edge, the left side, towards your target edge, the right side. A chain that has not yet touched the left edge at all reads zero, even if you have many stones on the board.

Watch this number climb as you play. If it stalls for several turns, you are placing stones that do not contribute to your main chain. If the computer's percentage is rising faster than yours, you need to start blocking or you will run out of time.

Mistakes that cost games

  • Playing only along the edge. Edge stones cover less ground and connect in fewer directions. The centre controls more paths.
  • Building a single narrow line. One block from the computer cuts it in half. Use bridges and parallel threats so the chain has more than one way forward.
  • Ignoring the computer's chain until it is too late. Check how far it has reached towards its edges. A chain at sixty percent is two or three moves from winning.
  • Reacting to every computer move instead of building your own plan. You have the first-move advantage. Use it by advancing your own chain and forcing the computer to react to you.
  • Forgetting that stones never move. Every stone is permanent. Placing one in a spot that helps nothing wastes your turn, and the game has a fixed number of turns.
  • Connecting to your edge too early at one end while ignoring the other. A chain anchored on the left but nowhere near the right is half finished and easy to cut.

Nothing leaves your browser

The board, the computer's thinking, and the score are all running inside this page. The random playouts happen on your own machine in plain code. There is no server, no account, and no data sent anywhere. Your best score is saved in local storage on this device. Once the page is loaded the game works without a network connection.

Help

How to play Hex

Your two edges are the left and the right; the computer is working top to bottom across the same cells you want. Nothing is ever captured or moved once placed, so each turn is a straight choice about which single hexagon matters most, and blocking the computer's chain and extending your own are usually the same move.

Tap any empty cell

Stones never move once placed.

Build left to right

Your two edges are the left and the right.

Block their chain

Blocking them and building yourself are the same move.

Watch your reach

The scoreboard shows how far across your chain has got.

Connect the sides

One unbroken chain wins it.

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

The bridge is the key shape

Two stones a knight’s move apart with two empty cells between them cannot be cut: whichever one is taken, you take the other. Play bridges rather than solid lines.

Attack and defend at once

Because there are no draws, any move that stops the computer connecting also helps you connect. There is no such thing as a purely defensive move.

The middle is worth more

A stone in the centre belongs to far more possible paths than one on the edge.

Going first is an advantage

It is a real one — Hex is a first-player win with perfect play on any board size. You get it.

Common questions

Can this game be drawn?
No. When a Hex board is full, one player always has a winning chain. That is a proven fact about the game, not a rule.
Which sides are mine?
The left and the right. The computer is joining top and bottom.
How does the computer choose?
It fills the rest of the board at random from each possible move, thousands of times over, and plays the one that wins most of those random finishes.
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.