Solving Connect 4 Variants
Check out Connect4.doc for a more structurised text
So how can you solve a game when your opponent is free to choose how he plays.
Well, suppose both players play absolutely perfect, they always make the best move
possible.
Will the game be a draw ?
It may come as a surprise to you but Connect 4 was already solved in 1988, by James
D Allen and Victor Allis independently.
And perhaps more surprisingly, the game won't be a draw !
In fact, it has been proven that White i.e. the first player, when playing perfectly,
will always win from black i.e. the second player ! No matter how good he is.
It's like to play and win from God ! :-)
On this page I will describe my strategies of perfect play for different board sizes.
Standard connect 4 is always played on a 7X6 board (7 columns, 6 rows).
It might be more appealing for you to check out strategies for the standard board
here
I'm sure anyone has played connect 4 sometime. So did I, but my fascination started
only a few years ago. I had found a Belgian game site, jippii and started playing
connect 4 quite often and as time passed, I became a really strong player. (ok, they
weren't many good opponents )
But that wasn't enough so I searched the internet for strategies and noticed
connect 4 was already solved for the 7X6 board.
But on jippii, it is a 7X7 board ! (I think they did it on purpose, to exclude
cheating)
So I started my own investigations and after about 3 months, I solved it !
OK, not for 100%, but certainly more than 99% :-)
And here too, White can win !! (although with a very different approach)
I could never solve it completely , the 7X7 board was way to big for my computer to
compute it. But I did find out that only very few positions made chance to be
guaranteed winning positions.
I memorised many interesting positions (including many positions for Black, to win
or to draw if possible)
and I can assure you, I was by far the best connect 4 player ever on jippii, without
cheating !!
and I almost always played as Black ! So I would be predestined to lose if anyone
played perfectly !
But no one ever did !! I had a record of 496 times in a row in which I did not lose
a single time. (while winning over 450 times)
Calcu, my name on jippii, was known to be nearly invincible. I was ! :-)
Wasn't that a great story ? :-)
But there's more.
Let me be the first to give strategies of perfect play for different board sizes
than 7X6.
All strategies are calculated for 100% so there's no doubt about it.
About the notation:
White, the first player, plays with an X
Black the second player, plays with an O
Ok, suppose white begins by putting his disc in column A.
1 A1
4
3
2
1 X
A B C D
That's quite simple, isn't it ?
The game could go on..
1 A1 C1
2 C2 D1
3 C3 D2
and so on…
4
3 X
2 X O
1 X O O
A B C D
Some additions with move 1 A1 as an example
1 !A1 strong move
1!!A1 very important move, if White made another move then Black, when playing
perfect, would change the result of the game.
If White could win with 1 A1, Black will at least draw from White
If White could draw with 1 A1,Black will win from White.
If White didn't make the 1!!A1 move but instead made 1 B1
I will write it down as 1 ?B1
1 A1 W+ White will win after 1A1 when playing perfect
1 A1 B+ Black will win after 1 A1 when playing perfect
1 A1 = The game will be a draw when both players play perfect
If I state multiple answers:
1 A1 !B1
!C1
than these are the best answers.
If the player has no advantage on a given board, his other answers would be denoted
with an ?
4X4 board
Black has an advantage on this board. White will find it very hard to win.
With perfect play, this board will result in a draw.
In the following positions, Black always plays perfect
The earliest wins for Black:
1A1 !B1
2?B2 !!B3 B+
4
3 O
2 X
1 X O
A B C D
1B1 !A1
2?B2 !!B3 B+
2?C1 !!D1 B+
4
3
2
1 O X X O
A B C D
1B1 !D1
2?B2 !B3 B+
4
3 O
2 X
1 X O
A B C D
4X6 board, 4X8 board, 4X10 board…
Black has an advantage on this board.
With perfect play, these boards will result in a draw.
The early wins for Black on the 4X4 board will also work for these boards.
4X5 board
Black has an advantage on this board.
With perfect play this board will result in a draw.
In the following positions, Black always plays perfect
As you will note, white will find it very hard to draw.
1A1 !A2
2!!A3 !A4
3!!A5 !D1 =
(Note the !!, after A1 was made, White had to make these moves or he will lose ! )
5 X
4 O
3 X
2 O
1 X O
A B C D
1B1 !B2
2!!B3 !B4 =
!D1 =
5
4
3 X
2 O
1 X O
A B C D
4X7 board, 4X9 board, 4X11 board...
Black has an advantage on this board.
With perfect play, these boards will result in a draw.
The strategies for the 4X5 board will also work for these boards.
5X4 board
Black has an advantage on this board.
With perfect play this board will result in a draw.
In the following positions, Black always plays perfect
As you will note, white will find it very hard to draw.
1?A1 !!B1 B+
4
3
2
1 X O
A B C D E
1B1 !D1
2!!D2 !D3
3!!D4 !B2 =
4 X
3 O
2 O X
1 X O
A B C D E
1 !B2
2!!D1 !C1
3!!D2 !B3=
!D3=
4
3 O
2 O X
1 X O X
A B C D E
1C1 !B1
2!!B3 !B3
3!!B4 !D1
4!!C2 =
3 !C2
4!!D1 =
4 X
3 O
2 X O
1 O X X
A B C D E
1C1 !C2
2!!C3 !C4
3!!B1 !D1
4!!D2 !D3
5!!D4 =
2 !B1
3!!B2 !!B3
4!!D1 !C4
5!!B4 =
4 O X
3 X O
2 O X
1 X X O
A B C D E
5X6 board
Black has a rather small advantage on this board.
With perfect play this board will result in a draw.
In the following positions, Black always plays perfect
As you will note, white will find it very hard to draw.
I adapted the strategies for the 5X4 board to this board.
On the 5X4 board, Black could force a win after 1.A1, here he can't but White has
to be very careful.
1A1 !B1
2!!B2 !B3
3!!B4 !B5
4!!D1 !!D2 =
6
5 O
4 X
3 O
2 X O
1 X O X
A B C D E
1B1 !D1
2!!D2 !!D3
3!!D4 !B2 =
6
5
4 X
3 O
2 O X
1 X O
A B C D E
1C1 !B1
2!!B2 !B3
3!!B4 !B5
4!!B6 !D1
5!!C2 =
4 !C2
5!!D1 =
6 X
5 O
4 X
3 O
2 X O
1 O X X
A B C D E
1C1 !C2
2!!C3 !C4 =
6
5
4 O
3 X
2 O
1 X
A B C D E
5X5 board
White has a small advantage on this board.
With perfect play this board will result in a draw.
In the following positions, White always plays perfect
1A1 ?A2
2!!B1 W+
1A1 ?C1
2!!C2 W+
1A1 !B1
2!B2 !!B3 =
1A1 !D1
2!D2 !!D3 =
1A1 !E1 (bad move)
2!E2 !!A2
3!D1 !!D2
4!B1 !!C1
5!B2 !!B3
5
4
3 O
2 O X O X
1 X X O X O
A B C D E
1B1 !B2 =
1 !E1
2B2 !!B3 =
5
4
3 O
2 X
1 X O
A B C D E
1C1 A1
2!C2 !!C3=
1C1 B1
2!C2 !!C3=
5
4
3 O
2 X
1 O X
A B C D E
1C1 !C2
2!!C3 =
6X4 board
Black has a huge advantage on this board.
With perfect play this board will result in a win for Black !
In the following positions, Black always plays perfect
1.C1 !!2.D1 B+
4
3
2
1 X O
A B C D E F
1.B1 !D1 B+
!B2 B+
4
3
2 O
1 X
A B C D E F
1.A1 !2C1 B+
!2D1 B+
4
3
2
1 X O
A B C D E F
With perfect play, black will also, most likely, win on a 6X6 board.
6X5 board
White has an advantage on this board.
With perfect play this board will result in a draw.
In the following positions, White always plays perfect
1B1 !B2
2!B3 !!D1
3!D2 !!D3
4!D4 !!B4
5!C1 =
5
4 O X
3 X O
2 O X
1 X X O
A B C D E F
1 !C1
2!C2 !!C3
3!B2 !!F1 (remarkable move)
4!C4 =
5
4 X
3 O
2 X X
1 X O O
A B C D E F
2!B2 !!C2
3!B3 !!B4
4!C3 !!C4 =
5
4 O O
3 X X
2 X O
1 X O
A B C D E F
1C1 !C2
2!D1 !!E1 =
5
4
3
2 O
1 X X O
A B C D E F
1 !D1
2!D2 !!C2
3!D3 !!D4
4!C3 !!E1
5!C4 !!F1
5
4 X O
3 X X
2 O X
1 X O O O
A B C D E F
1A1 is a rather bad move.
1A1 C1=
D1=
E1=
F1=
7X4 board
Black has a big advantage on this board.
With perfect play this board will result in a draw for Black !
In the following positions, Black always plays perfect.
1?A1 !B1 B+
!C1 B+
!D1 B+
!E1 B+
!F1 B+
1?B1 !D1 B+
!F1 B+
1?C1 !!C2 B+
1!!D1 !B1
2!!B2 !E1
3!!B3 !E2
4!!E3 !!E4 =
If White could reach this position (unlikely), he has a strong position, Black
should be careful now.
4 O
3 X X
2 X O
1 O X O
A B C D E F G
1 !C1
2!E1 !C2
3!!F1 !!G1
4!!F2 !C3
5!!C4 !!E2
6!!F3 !!F4
7!!E3 =
4 X O
3 O X X
2 O O X
1 O X X X O
A B C D E F G
1!!D1 D2
2!D3 !D4 =
!C1=
2!C1 !B1=
!E1=
8X4 board
Black has a huge advantage on this board.
With perfect play this board will result in a win for Black !
In the following positions, Black always plays perfect.
I have only searched for a1 possible winning strategie.
1A1 !D1 B+
1B1 !D1 B+
1C1 !C2 B+
1D1 !E1 B+