4 in a Row Best Move Calculator
Build any 4 in a Row position by dropping pieces into columns, and this solver will find the best column, rank all seven, and — the part that actually wins games — warn you which columns lose on the spot.
Built by Brian Hamilton
Drop some pieces into the columns, set whose turn it is, then press Find best move.
The move that loses on the spot
Most 4 in a Row games are not lost by missing a clever plan. They are lost by dropping a piece into a column and handing the opponent the square directly above it. Because pieces fall, every move you make builds a platform for your opponent — and if their winning square happens to sit on that platform, you have simply given them the game.
Neither side can win immediately here, so nothing looks urgent. Yet the calculator ranks column 4 last of the seven at every depth it searches, with a score just past −100,000. Anything beyond that five-figure mark is not a bad position — it is a forced loss. Before you read a single score, the tool also names the column outright: Do not play column 4.
The exact figure drifts a little as the search goes deeper — −100,003 at four ply, −100,009 at ten — because a forced result carries the remaining depth in its score so that a quick loss ranks below a slow one. The digits after the hundred thousand are a countdown, not a measurement.
Search deeper still and the news gets worse: by ten ply the calculator has worked out that five of Red’s seven columns lose by force, and only columns 2 and 3 hold. That is worth seeing, because from the board alone the position looks entirely playable.
The habit worth building: before you play a column, look at the square that will sit on top of your piece and ask whether it completes anything for your opponent. That one check prevents more losses than any amount of attacking play.
Why you win with two threats, never one
A single threat is easy to answer: your opponent simply blocks it. Games are won by creating two winning squares at once, because only one of them can be covered.
The calculator reports both winning columns in the results panel, and when your opponent has a double threat it reports theirs too. If two of your opponent’s columns are listed as immediate wins, the position is already lost and the tool will say so rather than pretending a best move exists.
Odd rows, even rows, and who runs out of moves
This is the idea that separates casual play from strong play, and it follows from something very simple: the board holds 42 pieces, Red takes 21 of them and Yellow 21, and columns fill from the bottom up. That means the parity of a threat square — whether it sits on an odd or even row counting from the bottom — decides who is eventually forced to give it away.
odd row — favours the player who moved first even row — favours the second player
As a rule of thumb in the endgame: Red, moving first, wants its threats on odd rows; Yellow wants its threats on even rows. When the rest of the board fills up and someone has to move somewhere, the parity decides who is forced to open the column containing the other player’s threat.
It is a guideline rather than a law — it applies most cleanly late in a game with a single threat each and no other options — but it explains a great many endings that otherwise look arbitrary. The results panel shows your odd and even threat counts separately so you can see which way a position is leaning.
The first player wins, in theory
4 in a Row is a solved game. With perfect play from both sides the first player wins, and the winning first move is the centre column. Play anywhere else on move one and the game is a draw with best play; play the outer two columns and the first player actually loses.
This calculator does not consult that solution. It searches and evaluates like any other engine, which is why it is honest about depth rather than claiming certainty. It does open in the centre column, but it works that out by searching rather than by looking it up.
What the calculator counts
| Pattern in any line of four | Mine | Theirs |
|---|---|---|
| All four filled | +10,000 | −10,000 |
| Three, with one empty | +50 | −80 |
| Two, with two empty | +8 | −9 |
| Centre column bonus | +3 centre, +2, +1, 0 at the edges — per piece | |
| Forced win or loss | ±100,000, plus the remaining depth | |
Look at the second and third rows: the opponent’s three is weighted at −80 against only +50 for your own, and their two at −9 against your +8. That is deliberate. The engine is tuned to block slightly harder than it attacks, which makes it a steadier opponent — and it is also why the score from Red’s point of view is not simply the negative of the score from Yellow’s.
How this calculator works
It is the engine that plays you on the 4 in a Row game page, given more time and asked to show all seven columns rather than pick one.
- Search: minimax with alpha–beta pruning, assuming best play from both sides.
- Column ordering: the centre is examined first, which prunes far more of the tree and buys extra depth for the same time.
- Iterative deepening against a time budget, keeping the deepest search that finished. Fast, Standard and Deep allow roughly 1, 3 and 7 seconds.
- Faster wins rank higher: a forced win carries the remaining depth in its score, so a win in two moves outranks the same win in six.
- Immediate wins and losing columns are computed exactly, not estimated. Those two lists do not depend on search depth at all, so they are reliable even on the Fast setting.
Where it is weak
- No opening book and no solution database. For the first dozen moves it is reasoning from a hand-written scoring table, and a solver that consults the solved game will out-argue it.
- The evaluation is not symmetric (see the table above). It is tuned for playing, not for adjudicating, so treat the raw score as a ranking device rather than an objective measure of the position.
- Parity is reported, not reasoned with. The search does not explicitly understand odd and even threats; it counts them for you to interpret.
- “Best” means best to the depth reached — which is why the depth is shown with every result.
Names, sizes and rules
The game is played on a grid seven columns wide and six rows high, pieces drop to the lowest free square, and the first player to line up four in any direction wins. If the board fills with no line, it is a draw.
You will see it called Four in a Row, Connect Four, Captain’s Mistress, Four Up and Plot Four. Connect Four is a registered trademark of Hasbro; this calculator is an independent tool and is not affiliated with or endorsed by them.
Variants on other grid sizes, and the “pop out” rules where a piece can be removed from the bottom of a column, are different games and are not covered here.
Play a full game
The analyser works on single positions. To play one out, the free 4 in a Row game uses this same engine at three difficulty levels or as pass-and-play. There are matching analysers for Checkers, Reversi and Nine Men’s Morris, and you may also like Gomoku and Super Tic-Tac-Toe, or the rest of the free online puzzle games.