Play free Hex on a board of hexagons against the computer at three levels, or with a friend on the same screen. One game, no draws.
Sky left to right 0
Rose top to bottom 0
Your move (Sky)
Scroll the board sideways to see all of it, or pick a smaller board.
Session You 0, Computer 0
Wins 0
Take turns placing one stone on any empty hexagon. Sky wins by making an unbroken chain of Sky stones from the left side to the right side; Rose wins by joining the top side to the bottom side. Each side's two edges are tinted in its colour, Sky stones carry a dot and Rose stones a diamond. A game cannot end in a draw. With the swap rule on, the second player may take over the first stone instead of placing one. Click a hexagon to place a stone. Arrow keys move along a row (left and right) or down and up the board (up goes to the upper left neighbour, down to the lower right one), Page Up and Page Down go to the upper right and lower left neighbours, Enter or Space places a stone.
Easy places a stone on a random empty hexagon that touches a stone already on the board. Medium plays about 500 random games to the end from the candidate moves and picks the move that did best; Hard plays about 8000, stopping after about 0.4 of a second at the latest (on a slower device that can mean fewer). Candidate moves are the empty hexagons within two steps of a stone, and games are spread over them so that promising moves get more of the playouts. It has no opening book and no knowledge of bridges or ladders beyond what the playouts show, so a careful player can beat it. With the swap rule on, the computer swaps when the first stone is two or more steps in from the edge (Easy swaps at random). Undo takes back your last move and the reply, and a game that used Undo is not counted as a result. Undo is not available once a game is over.
As-is, no warranty. These apps are free under their listed license and run entirely in your browser. Use at your own risk — don't blame me if your PC catches fire, your dog runs away, or the math turns out wrong. Verify anything that actually matters. None of this is professional financial, medical, legal, or engineering advice.
The board is a diamond of hexagons. Two players take turns placing one stone on any empty hexagon. Sky goes first and wants an unbroken chain of Sky stones from the left side to the right side. Rose wants an unbroken chain of Rose stones from the top side to the bottom side. Each hexagon touches up to six others, and a chain follows those touching edges. The first player to complete a chain wins.
Every game has a winner. When the board is completely full, exactly one of the two chains exists, so there are no draws, and blocking your opponent is the same thing as building your own chain. This is the main idea of the game: a wall that stops Rose from going top to bottom is itself a chain from left to right.
The sides of the board are tinted so you can see whose edge is whose: the left and right edges are Sky, the top and bottom edges are Rose, and the corners are split. Colour is not the only clue. Sky stones carry a round dot and Rose stones carry a diamond. The last stone placed has an amber rim, and at the end the winning chain is outlined in amber and pulses a few times.
Controls:
On the keyboard, Left and Right move along a row, Up goes to the upper left neighbour and Down to the lower right one, Page Up goes to the upper right neighbour and Page Down to the lower left one, Home and End jump to the ends of a row, and Enter or Space places a stone. Each hexagon is announced with its row, column and contents, and the status line says what each move did. The page address carries the opponent, difficulty, side, board size and swap rule.
The board is stored as a flat array of n times n cells. A cell’s six neighbours are the cells left and right of it, the two above it (straight up and up-right) and the two below it (down-left and straight down). The test suite checks this against a second definition that uses cube coordinates, where two cells touch exactly when they are one step apart, and it checks the count: a board n across has (n - 1)(3n - 1) pairs of touching cells.
To decide whether a player has won, the engine joins every pair of touching stones of that colour in a union-find structure, with two extra nodes standing for the player’s two sides. The player has won when the two side nodes end up in the same group. The test suite compares this with a flood fill written a different way:
The computer has three levels:
The candidate moves are the empty hexagons within two steps of a stone (or all of them when there are only a few). The random games are shared among the candidates by a rule that tries each once, then gives more games to the ones that win more often while still checking the others, and the move played is the one that received the most games. The computer opens in the centre. With the swap rule on, it opens one step in from the edge, and as the second player it swaps when the first stone is two or more steps in from the edge (Easy swaps at random, about half the time).
The suite counts the games through the random numbers they consume, so it proves that Medium plays 500 and Hard plays 8000. On 7 x 7 boards with colours alternating, Medium won at least 5 of 6 against Easy and so did Hard. Given a position where one stone completes its chain, Medium and Hard play that stone, which the suite checks on a 5 x 5 position with four different random seeds. The suite also asserts that Hard answers 11 x 11 positions in under 4 seconds, a bound loose enough for a slow machine; the design limit is 0.4 of a second. The computer waits about 0.4 seconds before moving so you can follow, and moves at once if you have asked for reduced motion.
Nothing is uploaded and there is no account. Against the computer, your win count for each difficulty is saved in your browser’s local storage, as small whole numbers inside a small JSON object, under one key. Clearing site data removes it. The session tally lives only on the page and resets when you leave it. Two-player games are not saved.
Only finished games count. A game in which you used Undo is not counted against the computer, so the saved figure is not inflated.
Everything runs locally in your browser.
For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.