Play Four in a Row Online
Drop your discs into one of the seven columns and be the first to line up four – horizontally, vertically or diagonally. Play the computer or a friend on the same device; your score is saved.
How it is calculated
How to play Four in a Row
The game is played on an upright board with 7 columns and 6 rows – 42 spaces in total. Two sides, here Blue and Orange, take turns choosing a column. The disc drops to the lowest free space in that column. The first side to get four of its own discs in a line wins: horizontally, vertically or diagonally. If the board fills up without a line of four, the game is a draw. The game is also known under other names; the rules are the same everywhere.
- Choose a mode: “Vs computer” (you play Blue) or “Two players” on one phone, tablet or computer.
- Who starts: you, the computer or alternate – with “Alternate” the other side starts each new round.
- Pick a column: tap or click anywhere in the column; on a keyboard use the arrow keys and Enter, or the digits 1–7.
The winning line is highlighted at the end. Orange discs also have a light centre so they can be told apart without relying on colour.
The three computer levels
- Easy: the computer takes a winning move and blocks your immediate threat of four; otherwise it picks a random column.
- Medium: it looks three plies ahead and scores positions by open lines of two and three.
- Hard: it searches nine plies ahead using negamax with alpha–beta pruning. It sets traps early and reliably spots simple threats. Among equally good moves it chooses at random, so games don’t repeat.
Tips to win more
- Centre first: the middle column is part of the most possible lines of four, so discs there are the most useful.
- Two threats at once: three in a row on the bottom with both ends open (_XXX_) can only be blocked on one side.
- Mind the order: never play directly below a space where your opponent would win with their next disc – you would be setting it up for them.
- Watch the diagonals: they are the lines players overlook most often.
Is the game solved?
Yes. In 1988 James D. Allen and Victor Allis independently showed that with perfect play the first player wins – provided they start in the middle column. The Hard computer does not search to the end of the game, so it can be beaten.
Score and privacy
Wins, losses and draws are counted separately for “Vs computer” and “Two players” and stored with your settings in your browser’s localStorage (key vierinreihe). Nothing is sent to a server. The computer’s randomness comes from the browser’s cryptography API.
More games: Tic-tac-toe, Sudoku, Hangman or the dice roller.
Frequently asked questions
How many rows and columns does the board have?
The board has 7 columns and 6 rows, 42 spaces in total. Each side therefore has at most 21 discs; if the board fills up without a line of four, the game is a draw.
Can you win diagonally?
Yes. Four discs in a line win horizontally, vertically and on both diagonals. A square of four discs does not count.
How do you always win?
Against a perfect opponent only the side that moves first can force a win – and only by starting in the middle column; this was worked out in 1988. In practice: take the centre, build two threats at once and never play below your opponent’s winning space.
What is the best strategy when going second?
Block the centre early, answer every immediate threat and look for spaces where your opponent cannot play without giving you a winning space above it. The Hard level is a good sparring partner for this.
Can I play with 2 players?
Yes, on one device: choose “Two players” and Blue and Orange take turns on the same phone, tablet or computer. The score for this mode is counted separately.
Who goes first?
You decide: you (Blue), the computer or alternate. With “Alternate” the other side starts each new round; the first round starts with Blue.
How strong is the Hard computer?
It looks nine plies ahead and reliably finds traps and threats. It does not search to the end of the game, so a well-prepared double threat that only pays off late can beat it.
Sources and legal basis
- Wikipedia: Connect Four (rules and solution)
- Wikipedia: Negamax
- Wikipedia: Alpha–beta pruning
- MDN: Crypto.getRandomValues()
As of:
Related tools
- Play tic tac toe onlineFree tic tac toe in your browser: play against the computer (easy, medium, unbeatable) or two players on one device, with a running score. No sign-up.
- Sudoku solver and online sudokuPlay sudoku online free in 4 levels or solve any puzzle: the sudoku solver explains every step. Notes, mistake check, hints and a printable grid.
- Play hangman onlineFree hangman game in your browser: 3,000 common English words in three levels, or enter your own secret word for a friend. Keyboard and touch, no sign-up.
- Play nonograms onlineFree nonogram puzzles in your browser: 5×5, 10×10 and 15×15, numbered levels and random puzzles – each with exactly one solution. With hints and error check.
- Play the mines game onlineFree mine puzzle in your browser: beginner, intermediate and expert, first click always safe, flags by long press or right click, best times. No app or sign-up.
- Play the 2048 game onlinePlay 2048 free in your browser: swipe or use the arrow keys to merge tiles until you reach 2048. With best score, one-step undo and your game saved.