WEBVTT
Kind: captions
Language: en-US

00:00:00.000 --> 00:00:03.450
This is a map of perfect play of Connect 4.

00:00:08.500 --> 00:00:13.449
Each branch emanating from this central node is a different connect 4 opening.

00:00:19.300 --> 00:00:25.750
Some are long and convoluted, but don't have much room for deviation, like this long, unbranching line.

00:00:28.600 --> 00:00:32.436
Some, on the other hand, have a whole bunch of variations on the 

00:00:32.486 --> 00:00:36.083
same theme, as indicated by this large blob of opportunities.

00:00:40.933 --> 00:00:46.883
But how can we come up with a connect 4 solution like this, which fits in a cute little graph?

00:00:46.933 --> 00:00:51.916
We start by imagining two omniscient gods playing a game of Connect 4.

00:00:51.966 --> 00:00:55.416
Players take turns dropping discs in the columns,

00:00:55.466 --> 00:00:58.416
and the first to make a line of 4 wins.

00:00:58.966 --> 00:01:00.416
What would happen?

00:01:00.466 --> 00:01:07.416
God 1, playing red, realizes that if he plays in the leftmost column, there is no path to victory.

00:01:07.466 --> 00:01:10.916
Starting one column over, he would lose as well!

00:01:10.966 --> 00:01:15.916
Starting almost in the center, he foresees that perfect play would yield a tie.

00:01:15.966 --> 00:01:21.916
But playing right in the center should result in victory, even against a flawless opponent.

00:01:21.966 --> 00:01:27.916
God 2, playing yellow, comes to the same realization, and promptly resigns.

00:01:27.966 --> 00:01:32.478
After analyzing millions of variations of every opening imaginable, God 2 

00:01:32.528 --> 00:01:36.916
realized there was no way of stopping God 1 from making a red line of 4.

00:01:36.966 --> 00:01:43.916
This was first discovered independently by computer scientists James Dow Allen and Victor Allis in 1988.

00:01:43.966 --> 00:01:46.916
They used strategies similar to the Gods:

00:01:46.966 --> 00:01:50.916
using computer programs to search all possible branches.

00:01:50.966 --> 00:01:54.416
Solutions like these make for great computer science,

00:01:54.466 --> 00:01:58.416
But as a human connect 4 player, it kind of leaves you wanting.

00:01:58.466 --> 00:02:02.916
Player 1 wins by playing in the center, but _why_?

00:02:02.966 --> 00:02:08.449
A computer, or a god, can evaluate billions of positions to check this result,

00:02:08.500 --> 00:02:10.983
But what's left for us humans?

00:02:11.033 --> 00:02:17.483
After player 1 plays in the center, what player 2 openings make it as hard as possible for player 1?

00:02:17.533 --> 00:02:25.483
To confuse red, should player 2 respond in the center, or one over? What about all the way on the side?

00:02:25.533 --> 00:02:30.044
Furthermore, is there some change of perspective that shows how us mortals 

00:02:30.094 --> 00:02:34.483
could hang on to the player one advantage, and defeat a perfect player 2?

00:02:34.533 --> 00:02:38.983
These questions went unanswered by those early solutions to Connect 4.

00:02:39.033 --> 00:02:43.483
But today, I'm going to show you connect 4 through the eyes of God 1.

00:02:43.533 --> 00:02:47.983
A simpler, more elegant solution, small enough to show on this screen.

00:02:48.033 --> 00:02:52.405
Because instead of relying on brute force search, I found a profoundly 

00:02:52.455 --> 00:02:56.516
simpler way to play perfect connect 4. All it takes is this graph.

00:02:59.566 --> 00:03:05.549
Suppose you're going to play as red, and you want a strategy to play your next game of connect 4 perfectly.

00:03:05.599 --> 00:03:10.049
What options are there, besides running brute force search in your head?

00:03:10.099 --> 00:03:14.049
Instead you could memorize every possibility upfront.

00:03:14.099 --> 00:03:18.049
That way you can just recall the right response during the game.

00:03:18.099 --> 00:03:24.049
Well, you'll need to memorize 90 gigabytes of connect 4 data, as this poor soul found out.

00:03:24.099 --> 00:03:31.049
These two strategies- brute force search and upfront memorization- both involve a large tree of positions.

00:03:31.099 --> 00:03:37.583
The difference is that just reading ahead makes you think a lot, and memorizing branches makes you remember a lot.

00:03:38.633 --> 00:03:43.583
The amount of positions to memorize up to a certain depth grows really fast.

00:03:43.633 --> 00:03:46.116
There's one empty position,

00:03:46.166 --> 00:03:49.149
7 options for the first move,

00:03:49.199 --> 00:03:52.649
49 two-move continuations,

00:03:52.699 --> 00:03:56.649
after 5 moves there's 4000 possibilities.

00:03:56.699 --> 00:04:02.683
and by the time we reach move 10, the number of positions we need to memorize is in the millions.

00:04:02.733 --> 00:04:07.183
Plotting the amount of positions up to n moves, we get a curve like this.

00:04:07.233 --> 00:04:09.683
Classic exponential growth.

00:04:10.733 --> 00:04:14.671
Now, after n moves have already been played, if we plot the amount 

00:04:14.721 --> 00:04:18.183
of work needed to brute-force solve the rest of the game...

00:04:18.233 --> 00:04:22.683
The amount of reading ahead required follows an opposite curve.

00:04:22.733 --> 00:04:25.683
For a game like this that's almost over,

00:04:25.733 --> 00:04:31.183
there's much less work needed to read through it, compared to brute forcing the opening position.

00:04:32.233 --> 00:04:35.183
This suggests a hybrid approach-

00:04:35.233 --> 00:04:38.216
Memorize all positions up to the midgame,

00:04:38.266 --> 00:04:41.216
and then we switch over to reading ahead.

00:04:41.266 --> 00:04:48.216
In other words, by balancing thinking hard and memorizing a lot, we can avoid these exponential explosions.

00:04:48.266 --> 00:04:52.952
This is why chess players memorize openings. By memorizing openings, you can 

00:04:53.002 --> 00:04:57.750
avoid the potential for making a mistake reading ahead, up to a certain depth.

00:04:57.800 --> 00:05:04.750
Eventually, the breadth of variations reachable at some depth is not memorizable, and you have to start thinking ahead.

00:05:05.800 --> 00:05:10.250
Victor Allis published a connect 4 solution like that in 1988.

00:05:10.300 --> 00:05:17.783
He found a table of 500,000 perfect openings, and a computer algorithm to solve endgames in a few seconds.

00:05:17.833 --> 00:05:22.283
Now I don't know about you, but I can't memorize half a million positions.

00:05:22.333 --> 00:05:25.975
Before I show you how to shrink that number by a factor of 100, 

00:05:26.025 --> 00:05:29.783
let me explain the trees that I've been showing in the background.

00:05:29.833 --> 00:05:35.283
If we add every possible connect 4 position to a tree, we get this gigantic thing.

00:05:35.333 --> 00:05:42.283
This full game tree up to move 5, taken as a guide on where to play, is called a 'strong solution'.

00:05:42.333 --> 00:05:47.783
However, it includes nodes where player 1, red, has already blundered.

00:05:47.833 --> 00:05:53.783
Remember, God 1 determined that starting all the way on the side is a losing first move...

00:05:53.833 --> 00:05:57.783
but it's recorded inside this strong solution graph.

00:05:57.833 --> 00:06:02.316
We don't want to memorize moves like those, since we'd never play them.

00:06:02.366 --> 00:06:06.316
So let's grab our hedge-trimmers and snip out all the mistakes...

00:06:06.366 --> 00:06:08.816
We get this smaller tree.

00:06:10.866 --> 00:06:13.350
We can shrink it further though.

00:06:13.400 --> 00:06:15.850
Consider this position.

00:06:15.900 --> 00:06:19.850
It's red's move, and there's two winning options.

00:06:19.900 --> 00:06:22.383
Red could either go here,

00:06:22.433 --> 00:06:24.383
or here.

00:06:24.433 --> 00:06:26.916
Everything else would be a blunder.

00:06:26.966 --> 00:06:29.416
Those two nodes are in our tree.

00:06:29.466 --> 00:06:34.416
But why memorize duplicates, instead of just memorizing the one we like better?

00:06:34.466 --> 00:06:37.416
Let's delete each duplicate option.

00:06:38.466 --> 00:06:43.714
This tree is sufficient- we can still play perfectly up to move 5 by memorizing 

00:06:43.764 --> 00:06:48.416
it. We've just cut out all of the stupid variations that we don't need.

00:06:48.466 --> 00:06:53.416
For that reason, we call this not a strong solution, but a weak solution.

00:06:54.466 --> 00:06:56.416
Check out this game.

00:06:58.966 --> 00:07:00.916
It's Red to move.

00:07:00.966 --> 00:07:05.916
Red is winning here. What do you think the weak solution looks like for this position?

00:07:05.966 --> 00:07:08.450
I'll give you a few options.

00:07:08.500 --> 00:07:10.983
Do you think it looks like this messy tree?

00:07:13.033 --> 00:07:15.483
Or this other messy tree?

00:07:17.533 --> 00:07:20.016
How about this third messy tree?

00:07:22.066 --> 00:07:26.016
Or do you think that it looks like this nice pillow shape?

00:07:26.066 --> 00:07:29.516
This isn't just some trivial question about appearance.

00:07:29.566 --> 00:07:36.016
If the weak solution is particularly simple, that means we can compress the information contained within it.

00:07:36.066 --> 00:07:40.016
So, make your guess! Which one do you think it is?

00:07:41.066 --> 00:07:44.050
The answer is... all of them!

00:07:45.100 --> 00:07:48.583
Remember how I chose between two winning options earlier?

00:07:48.633 --> 00:07:53.083
Up to the choices we make, we can get much different trees!

00:07:53.133 --> 00:08:00.583
This tree is what you get if any time there is a decision between two winning moves, you always choose the leftmost one.

00:08:00.633 --> 00:08:04.083
This tree involves always picking the rightmost option.

00:08:04.133 --> 00:08:08.583
This tree involves picking randomly between the winning options.

00:08:09.633 --> 00:08:12.616
But how on earth did I make this one?

00:08:12.666 --> 00:08:16.116
How do we identify these patterny weak solutions?

00:08:16.966 --> 00:08:20.450
I use what I call a 'steady state diagram'.

00:08:20.500 --> 00:08:27.450
The diagram is like a cheat-sheet, telling Red how to make all the right moves from here until the end of the game.

00:08:27.500 --> 00:08:30.950
To read it, there's a series of 8 priorities.

00:08:31.000 --> 00:08:35.450
It's red's turn. Let's follow the diagram to win the game.

00:08:35.500 --> 00:08:39.450
Rule 1: Can we win by making a line of 4?

00:08:39.500 --> 00:08:42.483
Nope. Move on to rule 2.

00:08:42.533 --> 00:08:46.483
Is the opponent about to win, such that we need to block it?

00:08:46.533 --> 00:08:48.483
Nope. Continue!

00:08:48.533 --> 00:08:51.516
Can we play on an exclamation mark?

00:08:51.566 --> 00:08:54.016
Yes! That's the move we'll make.

00:08:54.066 --> 00:09:01.016
Now, remember, this secret diagram tells _us_ what to do, but our opponent can fight back however they want!

00:09:01.066 --> 00:09:05.516
Our opponent chooses to block the threat. What should we do now?

00:09:06.166 --> 00:09:11.616
The first rule that applies now is rule 6, which says to play on a plus sign.

00:09:11.666 --> 00:09:14.150
Our opponent responds here.

00:09:14.200 --> 00:09:18.650
Try and figure out what Red should do next, according to the rules.

00:09:20.700 --> 00:09:25.150
There's only one at sign available now, so Red plays on it.

00:09:25.200 --> 00:09:31.650
As Red, if you follow this cheat sheet, regardless of what Yellow does, you'll eventually win the game.

00:09:39.700 --> 00:09:43.650
These diagrams are effectively a form of compression.

00:09:43.700 --> 00:09:47.682
By identifying such a simple program to play perfect endgames, 

00:09:47.732 --> 00:09:51.650
which describes a very compressible solution for our position,

00:09:51.700 --> 00:09:56.150
we can memorize that program instead of some convoluted search tree.

00:09:57.200 --> 00:10:00.650
So, what is the cheat sheet for the starting position?

00:10:00.700 --> 00:10:03.683
Unfortunately we're not that lucky.

00:10:03.733 --> 00:10:09.683
These diagrams are only good for describing midgames when the path to victory is already somewhat well-defined.

00:10:09.733 --> 00:10:12.216
So we're back to building trees.

00:10:12.266 --> 00:10:16.018
But this time, we can trim positions which have a steady state solution, 

00:10:16.068 --> 00:10:19.716
leaving us with the graph that I showed you in the start of this video.

00:10:22.766 --> 00:10:29.216
This is once again a weak solution. But, at every leaf node, instead of the game being over,

00:10:29.266 --> 00:10:35.250
we instead have a steady state diagram showing how to continue perfect play after that point,

00:10:35.300 --> 00:10:39.250
implicitly defining the remaining compressed game tree.

00:10:45.300 --> 00:10:50.250
This is just the compressed subgraph resulting from one particular leaf node.

00:10:50.300 --> 00:10:55.783
Imagine having to memorize those subtrees for every single leaf node on the graph!

00:10:55.833 --> 00:10:58.783
That's the degree of compression we're dealing with.

00:10:59.833 --> 00:11:03.783
The first thing you might notice about this graph is that it's symmetrical.

00:11:03.833 --> 00:11:10.783
This makes sense- If yellow plays on the left versus on the right, we'll respond in a way that is mirrored horizontally.

00:11:10.833 --> 00:11:16.783
There's a few exceptions to this rule. For example, this branch only has one asymmetric copy.

00:11:16.833 --> 00:11:23.816
In this case, both players made a perfectly symmetrical opening, and Red must pick a side to continue on.

00:11:23.866 --> 00:11:29.816
This opening is called the 6-1, because of the central column of 6 and neighboring column of 1.

00:11:30.866 --> 00:11:35.816
Let's shrink the graph even further, by fusing together mirror-symmetric nodes!

00:11:38.866 --> 00:11:43.316
This connect 4 solution has only 4,550 nodes!

00:11:43.366 --> 00:11:46.816
Comparing against Victor Allis's solution from the eighties,

00:11:46.866 --> 00:11:52.350
Allis's opening book was more than a hundred times as large, with half a million nodes.

00:11:53.400 --> 00:11:57.350
Furthermore, unlike the few seconds of search that Allis used,

00:11:57.400 --> 00:12:03.850
we don't need any search whatsoever since the steady state diagrams instantly tell us what to do in the endgame.

00:12:04.900 --> 00:12:08.850
This graph serves as a map of Connect 4 openings.

00:12:08.900 --> 00:12:13.850
Long branches represent openings which don't quickly simplify for player 1.

00:12:13.900 --> 00:12:19.883
They correspond quite well to openings which Connect 4 players actually study in practice.

00:12:19.933 --> 00:12:24.883
And this is great- it provides a framework to measure the difficulty of openings.

00:12:24.933 --> 00:12:30.416
For example, if player 2 plays like this, with player 1 following the solution,

00:12:34.466 --> 00:12:39.950
We run into a steady state right away, meaning Yellow didn't play a very challenging opening.

00:12:41.800 --> 00:12:44.750
What about the hardest opening for player 1?

00:12:44.800 --> 00:12:49.250
The first move which preserves the longest downstream subgraph is...

00:12:49.300 --> 00:12:51.250
One-off from center!

00:12:51.300 --> 00:12:57.250
Red, following the solution, is left with 2727 downstream nodes.

00:12:57.300 --> 00:13:04.283
One of the largest branches can be reached like this. It's the depth 8 position with the most downstream nodes.

00:13:04.333 --> 00:13:11.283
For connect 4 players, this probably isn't surprising. This is a very popular, very challenging opening.

00:13:13.333 --> 00:13:17.670
The center-column openings come in second place, also contributing a lot 

00:13:17.720 --> 00:13:21.816
of nodes to the graph. These first central moves are entirely forced.

00:13:21.866 --> 00:13:25.772
From here, a large amount of nodes are dedicated to variations of the 

00:13:25.822 --> 00:13:30.350
candlesticks opening, which involves making towers like so, which is also forced.

00:13:32.899 --> 00:13:36.350
We've covered a whole bunch of solutions to connect four.

00:13:36.399 --> 00:13:41.350
Brute force search relies intensively on reading ahead, but needs no memory.

00:13:42.000 --> 00:13:47.483
Memorizing the whole game tree before-hand takes up a ton of data, but no CPU.

00:13:47.533 --> 00:13:51.875
We can balance these extremes by memorizing openings and searching at 

00:13:51.925 --> 00:13:56.016
the end, demanding just a little memory and just a little compute.

00:13:56.066 --> 00:14:03.516
And finally, we can use pattern recognition to compress the tree upfront, demanding even less memory and compute,

00:14:03.566 --> 00:14:09.549
at the behest of a lot of resources used in upfront data compression, and pattern identification.

00:14:09.599 --> 00:14:14.049
In each case, we're just making trade-offs between different resources.

00:14:14.099 --> 00:14:18.549
Want to use less compute? That comes at the cost of other resources!

00:14:19.199 --> 00:14:24.149
This all begs the question- where is all this complexity coming from?

00:14:24.199 --> 00:14:28.649
A strong solution lookup table for the game takes up 90 gigabytes of data,

00:14:28.699 --> 00:14:33.649
and yet, the rules of the game can be defined in a single sentence of plain English.

00:14:34.699 --> 00:14:40.183
This video isn't about connect four. It's not entirely about computer science, either.

00:14:40.233 --> 00:14:45.183
It's about how systems yield complexity that can't be expressed in simpler terms.

00:14:45.233 --> 00:14:49.352
Just knowing the rules doesn't mean you can win without somehow 

00:14:49.402 --> 00:14:53.716
relying heavily on computation, raw memorization, or _something_...

00:14:53.766 --> 00:14:59.716
you can't just 'intuitively realize' that the candlesticks opening is a naturally arising strategy.

00:15:00.266 --> 00:15:06.716
Similarly, just knowing the laws of particle interactions doesn't mean you can predict the weather,

00:15:06.766 --> 00:15:10.216
and it doesn't tell you that there's such a thing as a cloud.

00:15:10.266 --> 00:15:14.716
But that doesn't stop us from discussing candlesticks openings or clouds.

00:15:14.766 --> 00:15:20.716
Maybe we can't concisely explain them from first principles, but that doesn't make them any less real.

00:15:20.766 --> 00:15:24.750
Clouds are best described not in the language of particle interations,

00:15:24.799 --> 00:15:28.750
but in the language of cold fronts, dew points, and vapor pressure-

00:15:28.799 --> 00:15:35.283
a whole new philosophy spawned out of thin air, far abstracted from any rules of physics or chemistry.

00:15:35.333 --> 00:15:39.005
Read all the physics textbooks you want- in none of them will you 

00:15:39.055 --> 00:15:42.783
find the rule that Cirrocumulus clouds cannot have species Volutus.

00:15:42.833 --> 00:15:47.476
There is no such rule, and yet we live in a world of intricate species of clouds, 

00:15:47.526 --> 00:15:52.283
with a whole subfield of meteorology concerned with their nomenclature and taxonomy.

00:15:52.333 --> 00:15:56.283
Connect 4 shows us a glimpse of that same emergent substance.

00:15:56.333 --> 00:16:00.283
It shows us that complexity and mystery aren't unique to those laws of 

00:16:00.333 --> 00:16:04.283
physics which gave us stars and galaxies, benzene rings and toothpaste.

00:16:04.333 --> 00:16:10.283
but are a mathematical inevitability more fundamental than physics, more real than reality.

00:16:10.933 --> 00:16:17.883
Equivalent magic arises from even the most humble systems of iterated rules, and this game is no exception.

00:16:17.933 --> 00:16:22.383
Complex enough to invoke that same spark of emergent fertility in full force,

00:16:22.433 --> 00:16:27.383
but simple enough that with modern computers, I can show you this graph and say,

00:16:27.433 --> 00:16:31.383
'Here is its shape. This is connect 4.'

00:16:39.433 --> 00:16:41.883
This has been 2swap,

00:16:41.933 --> 00:16:44.416
with music by 6884.

00:16:44.766 --> 00:16:48.749
I claim to have made a connect 4 solution that's human-memorizable,

00:16:48.799 --> 00:16:51.283
so let's put that to the test-

00:16:51.333 --> 00:16:57.316
I made a flash card deck using the spaced-repetition memorization app Anki, which I will attempt to learn!

00:16:57.366 --> 00:17:00.816
If you want to try too, you can download the deck in the description!

00:17:00.866 --> 00:17:04.816
I've also included a website where you can play against the weak solution,

00:17:04.866 --> 00:17:07.316
and explore the tree as you traverse it.

00:17:07.366 --> 00:17:10.349
Good luck winning... you'll need it!

00:17:11.399 --> 00:17:16.849
The site includes a lot of technical details which I glazed over, so be sure to check it out!

00:17:16.899 --> 00:17:21.966
I think the best way to learn the game is to play online, and in between rounds, review 

00:17:22.016 --> 00:17:26.849
the variations you played in the tree to see what a better response could have been.

00:17:26.899 --> 00:17:30.849
And that's where our sponsor, Opera Browser can help!

00:17:30.899 --> 00:17:38.349
Using Opera's split-screen browsing feature, you can easily replay your games in the tree alongside your online matches.

00:17:38.399 --> 00:17:45.849
In this case, we can see that I played out this variation of the 6-1 exactly as suggested by the solution graph!

00:17:45.899 --> 00:17:48.849
Want to read while waiting for an opponent?

00:17:48.899 --> 00:17:53.326
Just add another split-screen window! Opera lets you split your 

00:17:53.376 --> 00:17:57.383
view into two, three, or even four windows simultaneously.

00:17:57.433 --> 00:18:03.383
I found myself using Opera's tab islands to organize positions which I was in the process of analyzing.

00:18:03.433 --> 00:18:08.383
Opera automatically groups your tabs to keep everything in place, and you can name 

00:18:08.433 --> 00:18:13.383
or color-code these islands so you know exactly where your research is at a glance.

00:18:13.433 --> 00:18:18.040
I guess you could, like, use these features for organizing your research or travel plans 

00:18:18.090 --> 00:18:22.383
or something... but who am I kidding, this is practically made for connect 4 study.

00:18:22.433 --> 00:18:26.836
Opera is top-notch for productivity, especially with its Sidebar that 

00:18:26.886 --> 00:18:31.416
puts Google services like Gmail and Google Calendar just one click away.

00:18:31.466 --> 00:18:37.449
I can quickly check my schedule and my email without ever having to leave the page I’m working on.

00:18:37.499 --> 00:18:40.949
It also makes the YouTube experience more enjoyable.

00:18:40.999 --> 00:18:45.355
It has a video pop-out feature so that you can drag the video outside of your browser 

00:18:45.405 --> 00:18:50.016
window, letting you pretend that you're getting research done while watching 2swap instead.

00:18:50.066 --> 00:18:55.549
To try out Opera for yourself, click the link in the description to download it for free!

