How to win at Connect Four every time! A link to a game solver that you can use on your smartphone or computer – Mind Your Decisions (original) (raw)

I’ve written over 300 posts about game theory, and mostly the articles are about how game theory can be used to solve problems in business, politics, or real life–in other words, about anything other than games. Of course, game theory can be used to analyze actual games as well, and today’s example is about the winning strategy in a popular board game.

Connect Four is a two player board game similar to Tic-Tac-Toe. Each player takes turns dropping a colored disc into a board that has 7 vertical columns and 6 horizontal rows. The goal of the game is to connect four pieces of the same color–vertically, horizontally, or diagonally–before the other player does so. The game ends in a tie if neither player connects four when all the 42 board positions are filled up.

While the rules are simple, the game is surprisingly difficult to analyze. Even a simple question like “is there a winning strategy” becomes a complicated task. Strategies like “play in the center” and “make sure to block your opponent” will only take a player so far, and occasionally these strategies will lose. Trying to work out a winning strategy by trial and error would turn out to be an insurmountable task, as there are over 70 trillion possible Connect Four games.

Lucky for us, some people have worked out the game with computers and found the winning strategy. There is even a game solver that makes winning the game as easy as following directions from your smartphone.

UPDATE 11-2016 I have been told the solver linked in this post is not working. A commenter suggested the following website: Connect 4 solver (http://connect4.gamesolver.org/)

.
.

"All will be well if you use your mind for your decisions, and mind only your decisions." Since 2007, I have devoted my life to sharing the joy of game theory and mathematics. MindYourDecisions now has over 1,000 free articles with no ads thanks to community support! Help out and get early access to posts with a pledge on Patreon.

.
.

The first solutions of Connect Four

Here is a little bit of history on how the game was solved.

It is no small feat to solve the game, and remarkably two people in 1988 independently derived the answer. James D. Allen and Victor Allis both found that the first player has a winning strategy to the game. That’s the good news. The bad news is that the winning strategy is extremely complicated to describe. There are so many configurations of the board to consider. Additionally, one has to play very carefully because in many situations there is only one winning move, and every other move will be a losing move–allowing the second player to be able to force a win.

Comprehending the winning strategies as described, however, is no easy task. Allen’s explanation involves many new terms like aji, sente, and tenuki. Allis’s paper similarly employs the obscure vocabulary of threats, useless threats, baseinverse, and zugzwang. To get an appreciation for the complex strategy, just peruse one of the following documents: (Allen) Expert play in Connect Four or (Allis) A Knowledge-based Approach of Connect-Four.

Although a winning strategy has been described since 1988, there was not an easy way for a casual fan to utilize the knowledge. Now there is.

A game solver you can use from your smartphone!

This handy solver is the result of research from Dan Garcia, a professor of Computer Science at Berkeley.

Here is the URL:

http://cloud.cs.berkeley.edu:8090/gcweb/ui/game.jsp?game=connect4

connect4-solved

UPDATE 11-2016 I have been told the solver linked in this post is not working. A commenter suggested the following website: Connect 4 solver (http://connect4.gamesolver.org/)

Here are the steps on using the solver.

1. To solve for the classic game, go with the default option (of having 7 columns and 6 rows and 4 in a row wins.) You can change the options if you are playing on a different board.

2. Click “Play!” and you will see the board.

3. VERY IMPORTANT: You want to click the check-mark for “Move-values” under the heading “DISPLAY OPTIONS.” This option will display colors in each column. A green color indicates a winning move (this is where you should play), yellow indicates a tie, and red a losing move.

connect4-movevalue

4. Be the first person to move. Input your moves and your opponent’s moves and keep playing winning moves. You’ll win every time!

Here is an example of the steps. The board was chosen to be 7×6 with 4 in a row winning. I have selected the check-mark “Move-values” and I’m ready to play first.

Here is what the board looks like.

connect4-firstmove

It turns out the only winning move is to play in the center. I do this.

Now it’s the other player’s turn. The game solver illustrates that every move is losing–it doesn’t matter where the other player goes.

connect4-redlose

Suppose the other person plays directly on top in the center.

What to do now? The important thing is to follow the game solver. In this configuration, there is only one good move to play–all other moves will be losing (that is, it will allow the other player to win the game with proper play).

connect4-onlyonegoodmove

With perfect play from both sides, many games will take 41 (in other words, the board of 42 posts will almost entirely be filled up). I will not belabor you with the details of completing a game, but you get the idea of how the solver works.

If you diligently follow the steps of this tool, you can always win at Connect Four! It’s as easy as that.

Now the real trick will be finding a way to use the solver without the other person catching on. Coming up with a good excuse to keep checking your phone (you’re getting a lot of text messages?) will be the true test of a good strategist.

UPDATE 11-2016 I have been told the solver linked in this post is not working. A commenter suggested the following website: Connect 4 solver (http://connect4.gamesolver.org/)

MY BOOKS

If you purchase through these links, I may be compensated for purchases made on Amazon. As an Amazon Associate I earn from qualifying purchases. This does not affect the price you pay.

Book ratings are from January 2023.

(US and worldwide links)
https://mindyourdecisions.com/blog/my-books

Mind Your Decisions is a compilation of 5 books:

(1) The Joy of Game Theory: An Introduction to Strategic Thinking
(2) 40 Paradoxes in Logic, Probability, and Game Theory
(3) The Irrationality Illusion: How To Make Smart Decisions And Overcome Bias
(4) The Best Mental Math Tricks
(5) Multiply Numbers By Drawing Lines

The Joy of Game Theory shows how you can use math to out-think your competition. (rated 4.3/5 stars on 290 reviews)

40 Paradoxes in Logic, Probability, and Game Theory contains thought-provoking and counter-intuitive results. (rated 4.2/5 stars on 54 reviews)

The Irrationality Illusion: How To Make Smart Decisions And Overcome Bias is a handbook that explains the many ways we are biased about decision-making and offers techniques to make smart decisions. (rated 4.1/5 stars on 33 reviews)

The Best Mental Math Tricks teaches how you can look like a math genius by solving problems in your head (rated 4.3/5 stars on 116 reviews)

Multiply Numbers By Drawing Lines This book is a reference guide for my video that has over 1 million views on a geometric method to multiply numbers. (rated 4.4/5 stars on 37 reviews)

Mind Your Puzzles is a collection of the three "Math Puzzles" books, volumes 1, 2, and 3. The puzzles topics include the mathematical subjects including geometry, probability, logic, and game theory.

Math Puzzles Volume 1 features classic brain teasers and riddles with complete solutions for problems in counting, geometry, probability, and game theory. Volume 1 is rated 4.4/5 stars on 112 reviews.

Math Puzzles Volume 2 is a sequel book with more great problems. (rated 4.2/5 stars on 33 reviews)

Math Puzzles Volume 3 is the third in the series. (rated 4.2/5 stars on 29 reviews)

KINDLE UNLIMITED

Teachers and students around the world often email me about the books. Since education can have such a huge impact, I try to make the ebooks available as widely as possible at as low a price as possible.

Currently you can read most of my ebooks through Amazon's "Kindle Unlimited" program. Included in the subscription you will get access to millions of ebooks. You don't need a Kindle device: you can install the Kindle app on any smartphone/tablet/computer/etc. I have compiled links to programs in some countries below. Please check your local Amazon website for availability and program terms.

US, list of my books (US)
UK, list of my books (UK)
Canada, book results (CA)
Germany, list of my books (DE)
France, list of my books (FR)
India, list of my books (IN)
Australia, book results (AU)
Italy, list of my books (IT)
Spain, list of my books (ES)
Japan, list of my books (JP)
Brazil, book results (BR)
Mexico, book results (MX)

MERCHANDISE

Grab a mug, tshirt, and more at the official site for merchandise: Mind Your Decisions at Teespring.