99tools

3 in a Row & 4 in a Row

runs in your browser

Play tic-tac-toe or four in a row against a friend on one screen or against the computer at three levels. Undo, a running score, no sign-up.

The game

Play
Against
Level

Board

You 0 · The computer 0 · draws 0

You start this game; the start swaps each game.

Your turn

Tap a column to drop a disc; four in a line — across, up or on a slant — wins. On the board, the arrow keys pick a column and Enter or Down drops; 1 to 7 drop straight into a column.

about this tool

Two games of lines

Two of the oldest games for two players, on one page and one screen.

3 in a row is the game also known as tic-tac-toe, or noughts and crosses. X and O take turns to mark a square of a 3 × 3 grid; three in a line — across, down or corner to corner — wins, and a full grid with no line is a draw. Played well by both sides it is always a draw, which is exactly why the computer's hard level is worth trying to beat.

4 in a row is played on an upright board of seven columns and six rows. Red and yellow take turns to drop a disc into a column, and it falls to the lowest free space; the first to line up four — across, up, or on a slant — wins. Going first is an advantage, so the start swaps every game. The yellow discs carry a ring as well as their colour, so the two sides differ by more than colour alone.

Against a friend or the computer

Pass the screen between two people, or play the computer at one of three levels:

  • easy takes a win when it sees one and blocks yours, then looks only one move ahead and plays at random about a third of the time — beatable by anyone paying attention.
  • medium looks a few moves ahead and rarely slips.
  • hard looks up to seven moves ahead at 4 in a row — as far as it gets in under a tenth of a second, so a slow phone plays a little shallower rather than freezing — and searches 3 in a row to the very end, where it never loses.

Where several moves are equally good the computer picks one at random, with the same fair draw as the coin flip, so it does not play the same game every time.

Playing

Tap a square or a column. With a keyboard, the arrow keys move round the grid or along the columns and Enter plays; on the 4 in a row board, Down drops too, and the keys 1 to 7 drop straight into a column. A screen reader hears each column's discs from the bottom up. undo takes back the last move, and against the computer its reply too — after a game is over it takes the result back off the score as well; New game starts the next one, and the score above the board keeps count until you change the game or the opponent. A disc falls into place in a fraction of a second, or simply appears for anyone who has asked their device for less motion.

For a puzzle on your own, there is Minesweeper and Sudoku.

questions

How do I play 3 in a row?
It is the game also called tic-tac-toe, or noughts and crosses: X and O take turns to put their mark in a square of a 3 × 3 grid, and the first to get three in a line — across, down or corner to corner — wins. If the grid fills with no line, it is a draw.
How do I play 4 in a row?
Red and yellow take turns to drop a disc into one of seven columns, and it falls to the lowest free space. The first to line up four — across, up, or on a slant — wins; a full board with no four is a draw. Tap a column, or pick one with the arrow keys and press Enter, or press 1 to 7.
Can I play against the computer?
Yes, at three levels. At every level the computer takes a win when it has one and blocks yours when you are one move away. Easy then looks one move ahead and plays at random about a third of the time; medium looks a few moves ahead; hard looks up to seven moves ahead at 4 in a row — as far as it can in a moment, so a slow phone never freezes — and all the way to the end at 3 in a row, where it never loses: the best you can do is draw.
Who goes first?
The first game starts with you, or with X or red against a friend, and after that the start swaps every game, since going first is an advantage in both. Changing the game or the opponent starts the score again.
Can I take a move back?
Yes: undo takes back the last move, and against the computer it takes back its reply too, so it is your turn again. Undo works after a game is over, too, to see what else could have happened — and takes that result back off the score.
Is anything saved or sent?
No. The games run in your browser, the computer thinks on your device, and its random choices — between equally good moves, and its slips on easy — come from the browser’s cryptographic randomness. Nothing is stored or sent; the score lasts until you leave the page.