It's tough, but yes. On the "Very hard" level the machine uses minimax search with alpha-beta pruning and a strong positional evaluation, looking several moves ahead. Unlike tic-tac-toe, Four in a Row has far too many possible positions to calculate exhaustively, so the search is depth-limited. That makes it very hard to beat, but not perfect, in complex positions it can miss the theoretically ideal move.
Four in a Row
Four in a Row
Line up 4 pieces before the computer (or a friend) does. Classic strategy on a 7×6 board.
The classic drop-token game, with a real AI
Four in a Row is the classic strategy game where two players take turns dropping pieces into a vertical board with 7 columns and 6 rows: each piece falls to the lowest open spot in the chosen column, and the first to line up 4 pieces in a row, horizontally, vertically, or diagonally in either direction, wins. You can play against the computer at three levels or against a friend on the same device. On the higher levels, the machine uses the minimax algorithm with alpha-beta pruning and scores each position by weighing in-a-row threats and the value of the center columns. Because Four in a Row has vastly more possible positions than tic-tac-toe, that search is depth-limited, so even on the hardest level the AI isn't perfect, just very hard to beat. The score is saved in your browser and the winning line is highlighted automatically.
Pick a mode and start dropping pieces
- Choose to play against the computer (and the level) or in 2-player mode.
- Tap anywhere in a column to drop your piece there; you always start with the red pieces.
- Line up 4 pieces to win; use "Play again" for the next round and keep an eye on the scoreboard.