Connect Four
Play Connect Four against the computer on easy, medium or hard, or with a friend on one device. Get four in a row. Keyboard friendly, works offline.
How is this calculated?
A line is four in a row of one colour: 69 possible lines on a 7 × 6 board. The computer scores positions by open lines of two and three and searches 2, 4 or 7 moves ahead.Runs in your browser — nothing you enter leaves this device.
About this tool
What it does
Connect Four is the two-player game of dropping coloured discs into a seven-column, six-row board: each disc falls to the lowest free space in its column, and the first player to make a line of four of their colour — across, up and down, or diagonally — wins. If the board fills with no line of four, it is a draw. Play against the computer or with a friend taking turns on the same phone or computer. Against the computer you play red and go first; choose Easy, which looks two moves ahead and sometimes plays loosely, Medium, which looks four ahead, or Hard, which looks seven moves ahead and is difficult to beat. The computer never cheats: it sees the same board you do and chooses its move by searching the possible replies (minimax with alpha-beta pruning), preferring the middle columns, where most lines can be made. Wins in a row against the computer are counted, and your best run is kept on this device. Drop a disc with the arrow buttons above the board, or by clicking a column.
How to use it
- Choose the computer (and its strength) or a friend.
- Drop a disc with a column button, or click the column.
- Block your opponent’s threes, and build lines that can be finished two ways.
- Press New game to play again.
Limits and your data
- Two-player mode is on one device; there is no online play.
- On Hard, the computer can take a moment on an older phone to choose its move.
- The game, including the computer player, runs in your browser. Nothing is sent anywhere.
Questions
Who goes first?
Red. Against the computer you are red; with a friend, red starts and you take turns.
Is there a strategy to win?
Take the middle column early, block every three, and look for a move that makes two threats at once — the opponent can only block one.
Can Connect Four always be won?
With perfect play, the first player can always win by starting in the middle column; it was solved by computer in 1988.
Can I play with the keyboard?
Yes. Tab to the column buttons above the board and press Enter or Space to drop a disc.