WEBVTT

00:00:00.070 --> 00:00:02.500
The following content is
provided under a Creative

00:00:02.500 --> 00:00:04.019
Commons license.

00:00:04.019 --> 00:00:06.360
Your support will help
MIT OpenCourseWare

00:00:06.360 --> 00:00:10.730
continue to offer high quality
educational resources for free.

00:00:10.730 --> 00:00:13.340
To make a donation or
view additional materials

00:00:13.340 --> 00:00:17.229
from hundreds of MIT courses,
visit MIT OpenCourseWare

00:00:17.229 --> 00:00:17.854
at ocw.mit.edu.

00:00:21.066 --> 00:00:24.390
PROFESSOR: Today we're going
to be talking about games.

00:00:24.390 --> 00:00:29.724
And I know you guys as
well as I hope I do.

00:00:29.724 --> 00:00:32.140
The main thing that you guys
want to talk about with games

00:00:32.140 --> 00:00:34.330
is how to do that
alpha-beta thing.

00:00:34.330 --> 00:00:36.300
Because it's pretty confusing.

00:00:36.300 --> 00:00:40.490
And it's easy to get lost
in a corner or something.

00:00:40.490 --> 00:00:43.820
Whereas doing the regular
minimax, in my experience,

00:00:43.820 --> 00:00:45.590
most 6034 students can do that.

00:00:45.590 --> 00:00:48.450
And they do it right
pretty much all the time.

00:00:48.450 --> 00:00:51.560
However, we're going to focus
on all the different components

00:00:51.560 --> 00:00:52.940
of games.

00:00:52.940 --> 00:00:56.910
And I put up two provocative
silver star ideas

00:00:56.910 --> 00:01:00.370
up on the board, which
will come into play here.

00:01:00.370 --> 00:01:02.840
The Snow White
principle is a new name.

00:01:02.840 --> 00:01:05.489
And it has never been
revealed until today.

00:01:05.489 --> 00:01:08.050
Because I made up name recently.

00:01:08.050 --> 00:01:11.000
So you will be the first
people to hear it and decide

00:01:11.000 --> 00:01:13.310
if it works better than
the term "grandfather

00:01:13.310 --> 00:01:15.630
clause" for the thing that
I'm trying to describe.

00:01:15.630 --> 00:01:19.420
Because most grandfathers
don't eat their children.

00:01:19.420 --> 00:01:25.300
So here we've got a
beautiful game tree.

00:01:25.300 --> 00:01:29.970
It has nodes from
A through R. This

00:01:29.970 --> 00:01:33.250
is our standard
game tree from 6034.

00:01:33.250 --> 00:01:35.922
We've got a maximizer
up at the top

00:01:35.922 --> 00:01:37.880
who's trying to get the
highest score possible.

00:01:37.880 --> 00:01:41.770
The minimizer is her opponent.

00:01:41.770 --> 00:01:44.530
And the minimizer is trying
to get to the lowest score

00:01:44.530 --> 00:01:45.930
possible.

00:01:45.930 --> 00:01:49.264
And it's really unclear who
wins or loses at each point.

00:01:49.264 --> 00:01:51.680
They're just trying to get it
to the highest or the lowest

00:01:51.680 --> 00:01:54.140
score.

00:01:54.140 --> 00:01:56.660
All right, so let's
do a refresher.

00:01:56.660 --> 00:01:59.590
Hopefully the quiz didn't put
people into such panic modes

00:01:59.590 --> 00:02:01.180
that they forgot
Monday's lecture.

00:02:01.180 --> 00:02:06.130
So let's make sure that
we can do regular minimax

00:02:06.130 --> 00:02:09.639
algorithm on this tree
and figure out the minimax

00:02:09.639 --> 00:02:11.270
value at A.

00:02:11.270 --> 00:02:13.900
So let's see how that works.

00:02:13.900 --> 00:02:19.010
All right, as you guys
remember, the game search

00:02:19.010 --> 00:02:22.320
when using regular
minimax is essentially

00:02:22.320 --> 00:02:24.550
a depth first search.

00:02:24.550 --> 00:02:28.080
And at each level, it
chooses between all

00:02:28.080 --> 00:02:32.510
of the children whichever
value that the parent wants.

00:02:32.510 --> 00:02:35.480
So here after it would choose
the maximum of K and L,

00:02:35.480 --> 00:02:36.330
for instance.

00:02:36.330 --> 00:02:37.570
But that's getting
ahead of ourselves.

00:02:37.570 --> 00:02:38.986
Because it's a
depth first search.

00:02:38.986 --> 00:02:40.874
So we best start at the top.

00:02:40.874 --> 00:02:42.290
I'll help you guys
up for a while.

00:02:42.290 --> 00:02:44.480
So we're doing A. We
need the maximum of B, C,

00:02:44.480 --> 00:02:45.770
D, depth first search.

00:02:45.770 --> 00:02:49.760
We go to B. We're looking
for the minimum of E and F.

00:02:49.760 --> 00:02:55.980
So having looked at E, our
current minimum of E and F

00:02:55.980 --> 00:02:58.780
is just 2 for the moment.

00:02:58.780 --> 00:03:04.040
So this is going to be
less than or equal to 2.

00:03:04.040 --> 00:03:06.690
All right, then we go down
to F, which is a maximizer.

00:03:06.690 --> 00:03:09.850
And its children are
K and L. So now I'm

00:03:09.850 --> 00:03:11.650
going to start making
you guys do stuff.

00:03:11.650 --> 00:03:13.960
So what do you think?

00:03:13.960 --> 00:03:17.620
What is going to be
the minimax value at F?

00:03:17.620 --> 00:03:20.659
The minimax value at
F, what will that be?

00:03:20.659 --> 00:03:21.534
AUDIENCE: [INAUDIBLE]

00:03:25.150 --> 00:03:29.090
PROFESSOR: So that level is
a maximizer-- max, min, max.

00:03:29.090 --> 00:03:30.280
F is a maximizer.

00:03:30.280 --> 00:03:32.420
K and L themselves
are minimizers.

00:03:32.420 --> 00:03:34.200
But they're pretty
impotent minimizers.

00:03:34.200 --> 00:03:35.590
Because they don't
get to choose.

00:03:35.590 --> 00:03:39.950
They just have to do K or L.
So the minimax value is three.

00:03:39.950 --> 00:03:42.660
And yeah, the path it
would like to go is K.

00:03:42.660 --> 00:03:45.510
So we'll say that the
minimax value here is 3.

00:03:45.510 --> 00:03:48.680
It's in fact exactly equal to 3.

00:03:48.680 --> 00:03:53.410
So if this is 3 and this
is 2, then everyone,

00:03:53.410 --> 00:03:55.476
we know that the value of B is?

00:03:55.476 --> 00:03:57.710
AUDIENCE: [INAUDIBLE]

00:03:57.710 --> 00:03:58.960
PROFESSOR: I hear 3 and 2.

00:03:58.960 --> 00:04:00.281
Which one is it?

00:04:00.281 --> 00:04:00.780
AUDIENCE: 2.

00:04:00.780 --> 00:04:03.150
PROFESSOR: 2, that's right.

00:04:03.150 --> 00:04:04.600
So the value here is 2.

00:04:04.600 --> 00:04:06.790
Great, let's go down
into this branch.

00:04:06.790 --> 00:04:09.427
So C is going to be
the minimum of G and 6.

00:04:09.427 --> 00:04:10.510
But we don't see that yet.

00:04:10.510 --> 00:04:12.218
Because we're doing
a depth first search.

00:04:12.218 --> 00:04:13.840
It's going to be
the minimum of G.

00:04:13.840 --> 00:04:16.540
Now we need the
maximum of M and N.

00:04:16.540 --> 00:04:18.160
We're going to need the minimum.

00:04:18.160 --> 00:04:23.530
M is the minimum of Q and
R. So let's switch sides.

00:04:23.530 --> 00:04:27.100
The minimum of Q and R is?

00:04:27.100 --> 00:04:28.305
AUDIENCE: 1.

00:04:28.305 --> 00:04:29.180
PROFESSOR: Let's see.

00:04:29.180 --> 00:04:30.570
That's right, it's 1.

00:04:30.570 --> 00:04:32.170
So M has a value of 1.

00:04:32.170 --> 00:04:34.240
But I'm going to stay over here.

00:04:34.240 --> 00:04:36.140
Because M has a value of 1.

00:04:36.140 --> 00:04:39.100
Knowing that, then we know
that G has a value of?

00:04:39.100 --> 00:04:39.600
AUDIENCE: 7

00:04:39.600 --> 00:04:40.600
PROFESSOR: That's right.

00:04:40.600 --> 00:04:41.930
7 is higher than 1.

00:04:41.930 --> 00:04:45.550
And since G is a 7, we
now know going up to C

00:04:45.550 --> 00:04:47.850
that C has a value of?

00:04:47.850 --> 00:04:48.850
AUDIENCE: 6.

00:04:48.850 --> 00:04:50.830
PROFESSOR: Yes, C
has a value of 6.

00:04:50.830 --> 00:04:52.710
That's the minimum 6 and 7.

00:04:52.710 --> 00:04:54.600
So now I'm going
to go back down.

00:04:54.600 --> 00:04:57.370
Because we've done one
of the other sub-trees.

00:04:57.370 --> 00:04:58.751
This is a 6.

00:04:58.751 --> 00:04:59.950
All right, great.

00:04:59.950 --> 00:05:03.900
Now we're going to go down to D.
Hopefully it won't be too bad.

00:05:03.900 --> 00:05:05.760
These things usually
aren't terrible.

00:05:05.760 --> 00:05:08.710
Because they're made to be
pruned a lot in alpha-beta.

00:05:08.710 --> 00:05:12.350
So let's see, in D, we go down
to I. And that's just a 1.

00:05:12.350 --> 00:05:17.040
We go down to J. And let's see,
what's the minimax value of J?

00:05:17.040 --> 00:05:17.860
AUDIENCE: It's 20.

00:05:17.860 --> 00:05:18.860
PROFESSOR: That's right.

00:05:18.860 --> 00:05:21.120
20 is the maximum of 20 and 2.

00:05:21.120 --> 00:05:24.780
Great, so what's the
minimax value of D?

00:05:24.780 --> 00:05:25.990
Everyone said it-- 1.

00:05:25.990 --> 00:05:27.946
All right, so what's
the minimax value at A?

00:05:27.946 --> 00:05:29.574
AUDIENCE: 6.

00:05:29.574 --> 00:05:30.490
PROFESSOR: 6 is right.

00:05:30.490 --> 00:05:31.660
6 is higher than 2.

00:05:31.660 --> 00:05:32.740
It's higher than 1.

00:05:32.740 --> 00:05:34.020
Our value is 6.

00:05:34.020 --> 00:05:41.960
And our path is-- everyone--
A, C, H. That's it.

00:05:41.960 --> 00:05:46.329
Great, is everyone
good with minimax?

00:05:46.329 --> 00:05:47.995
I know that usually
a lot of people are.

00:05:47.995 --> 00:05:49.510
There's usually a few
people who aren't.

00:05:49.510 --> 00:05:50.950
So if you're one
of the people who

00:05:50.950 --> 00:05:54.150
would like some clarifications
on minimax, raise your hand.

00:05:54.150 --> 00:05:58.680
There's probably a few other
people who would like some too.

00:05:58.680 --> 00:06:00.536
OK.

00:06:00.536 --> 00:06:03.350
AUDIENCE: When you're doing
this minimax, whatever values

00:06:03.350 --> 00:06:06.752
are not showing, you
keep going down the tree

00:06:06.752 --> 00:06:08.452
and then just look
at whether you're

00:06:08.452 --> 00:06:09.670
trying to find the minimax.

00:06:09.670 --> 00:06:12.380
And just whatever values
you get you go back up one?

00:06:12.380 --> 00:06:14.710
PROFESSOR: Yes.

00:06:14.710 --> 00:06:20.340
The question was, when you go
to do the minimax-- and let's

00:06:20.340 --> 00:06:21.724
say you got E was
2, and you know

00:06:21.724 --> 00:06:23.640
that B is going to be
less than or equal to 2,

00:06:23.640 --> 00:06:25.160
but you don't know F yet.

00:06:25.160 --> 00:06:28.350
The question is, do you go down
the tree, find the value at F,

00:06:28.350 --> 00:06:29.460
and then go back up?

00:06:29.460 --> 00:06:31.270
The answer is yes.

00:06:31.270 --> 00:06:33.300
By default, we use a
depth first search.

00:06:33.300 --> 00:06:36.550
However, in non alpha-beta
version, just regular minimax,

00:06:36.550 --> 00:06:40.900
it turns out it probably
doesn't matter what you do.

00:06:40.900 --> 00:06:43.150
I suggested doing a depth
first search to get yourself

00:06:43.150 --> 00:06:44.630
in the mindset of alpha-beta.

00:06:44.630 --> 00:06:49.290
Because order is very, very
important in alpha-beta.

00:06:49.290 --> 00:06:52.150
But here, I don't know, you
could do some weird bottom

00:06:52.150 --> 00:06:53.110
up search.

00:06:53.110 --> 00:06:56.010
Whatever you want, it's going
to give you the right answer

00:06:56.010 --> 00:06:58.380
unless it asks what
order they evaluated.

00:06:58.380 --> 00:06:59.280
But here's a hint.

00:06:59.280 --> 00:07:03.790
The order they're evaluated in
is depth first search order.

00:07:03.790 --> 00:07:09.620
So without even doing anything,
E, K, L, Q, R, N, H, I, O, P

00:07:09.620 --> 00:07:13.355
are the order of starting
evaluation in this tree.

00:07:13.355 --> 00:07:14.230
AUDIENCE: [INAUDIBLE]

00:07:20.330 --> 00:07:23.950
PROFESSOR: So the question
is, nodes like M and G

00:07:23.950 --> 00:07:26.130
we don't have to
put values next to.

00:07:26.130 --> 00:07:28.420
Technically, if we were
doing this very formally,

00:07:28.420 --> 00:07:30.560
and we couldn't
remember, and I wasn't

00:07:30.560 --> 00:07:33.780
up there among the people,
we would put 1 there.

00:07:33.780 --> 00:07:36.580
So at M, we would put a 1.

00:07:36.580 --> 00:07:37.829
But people remembered that.

00:07:37.829 --> 00:07:38.620
So we didn't do it.

00:07:38.620 --> 00:07:40.599
But then at G, we would put a 7.

00:07:40.599 --> 00:07:42.390
So if we were writing
it out very formally,

00:07:42.390 --> 00:07:45.280
we would have a 1 and a 7.

00:07:45.280 --> 00:07:47.920
And at this D, we
would have a 1.

00:07:47.920 --> 00:07:50.650
And then at the A,
we would put a 6.

00:07:50.650 --> 00:07:53.140
And then that's the answer.

00:07:53.140 --> 00:07:55.510
Also, we've even put things
like less than or greater

00:07:55.510 --> 00:07:57.070
than part way along the way.

00:07:57.070 --> 00:08:00.590
However, I believe that
our alpha-beta search

00:08:00.590 --> 00:08:03.960
is going to definitely
fulfill everyone's quota

00:08:03.960 --> 00:08:07.030
of pedantically putting lots
of numbers next to nodes

00:08:07.030 --> 00:08:08.650
on a game tree.

00:08:08.650 --> 00:08:11.470
And so once you've
done alpha-beta,

00:08:11.470 --> 00:08:13.870
if you can do it
correctly, you'll

00:08:13.870 --> 00:08:16.260
think, oh, minimax, oh,
those were the days.

00:08:16.260 --> 00:08:17.590
It's going to be easy.

00:08:17.590 --> 00:08:22.170
Because alpha-beta is a
little bit more complicated.

00:08:22.170 --> 00:08:24.490
There's a lot of things
that trip people up here.

00:08:24.490 --> 00:08:26.270
For alpha-beta,
however, I will erase

00:08:26.270 --> 00:08:28.750
some of these numbers
for the moment.

00:08:28.750 --> 00:08:30.660
They're still right.

00:08:30.660 --> 00:08:33.700
But we do it a
little differently.

00:08:33.700 --> 00:08:38.470
So what do alpha-beta and
beta add to this formula?

00:08:38.470 --> 00:08:40.710
Well, this is all sort
of a winning formula,

00:08:40.710 --> 00:08:41.679
except for it's not.

00:08:41.679 --> 00:08:43.490
Because it takes too long.

00:08:43.490 --> 00:08:45.620
But it's a very nice formula.

00:08:45.620 --> 00:08:47.600
U is the maximizer, say.

00:08:47.600 --> 00:08:50.410
I would try to think, if I do
this, what's he going to do?

00:08:50.410 --> 00:08:52.430
And then if he does that,
what am I going to do?

00:08:52.430 --> 00:08:54.340
And then what is
he going to do if I

00:08:54.340 --> 00:08:57.040
do that, et cetera, et cetera,
all the way to the bottom.

00:08:57.040 --> 00:08:58.560
With alpha and
beta, we add in what

00:08:58.560 --> 00:09:02.644
I like to call nuclear options.

00:09:02.644 --> 00:09:04.560
I'd like in this game
of maximizer minimizer--

00:09:04.560 --> 00:09:07.389
you can think of it as like the
Cold War or the Peloponnesian

00:09:07.389 --> 00:09:09.680
War, except the Peloponnesian
War didn't have nukes, so

00:09:09.680 --> 00:09:12.710
probably the Cold War.

00:09:12.710 --> 00:09:17.200
And in the Cold War,
or any situation

00:09:17.200 --> 00:09:19.477
where you're up against an
adversary who-- actually,

00:09:19.477 --> 00:09:21.560
this doesn't really work
as well for the Cold War.

00:09:21.560 --> 00:09:22.935
But in any situation
where you're

00:09:22.935 --> 00:09:24.920
up against an adversary
whose only goal in life

00:09:24.920 --> 00:09:27.260
is to destroy you,
you always want

00:09:27.260 --> 00:09:29.480
to find out what the best
thing you can possibly do

00:09:29.480 --> 00:09:32.850
is if they hit that button
and send nukes in from Cuba,

00:09:32.850 --> 00:09:36.270
or if they send fighter pilots,
or whatever is going on.

00:09:36.270 --> 00:09:38.600
So the idea of alpha
and beta is that they

00:09:38.600 --> 00:09:45.030
are numbers that represent
the fail-safe, the worst case.

00:09:45.030 --> 00:09:47.590
Because obviously
in the Cold War,

00:09:47.590 --> 00:09:50.820
sending nukes was
not a good plan.

00:09:50.820 --> 00:09:55.230
But presumably, us
sending nukes would

00:09:55.230 --> 00:09:57.880
be better than just being
attacked and killed.

00:09:57.880 --> 00:10:04.150
So the alpha and beta represent
the worst possible outcome

00:10:04.150 --> 00:10:07.470
you'd be willing to
accept for your side.

00:10:07.470 --> 00:10:10.080
Because right now,
you know you're

00:10:10.080 --> 00:10:15.400
guaranteed to be able to force
the conflict to that point

00:10:15.400 --> 00:10:16.840
or better.

00:10:16.840 --> 00:10:19.780
So the alpha is the nuclear
option, the fail-safe,

00:10:19.780 --> 00:10:22.420
of the maximizer.

00:10:22.420 --> 00:10:27.890
Nuclear options-- alpha is
maximizer's nuclear option.

00:10:34.980 --> 00:10:40.430
And beta is the
minimizer's nuclear option.

00:10:46.994 --> 00:10:49.410
So we ask ourselves-- and
people who were paying attention

00:10:49.410 --> 00:10:52.240
at lecture or wrote stuff
down know the answer already--

00:10:52.240 --> 00:10:55.240
what could we possibly
set to start off?

00:10:55.240 --> 00:10:57.230
Before we explore the
tree and find anything,

00:10:57.230 --> 00:10:59.760
what will we set as
our nuclear option,

00:10:59.760 --> 00:11:01.280
as our sort of fail-safe?

00:11:01.280 --> 00:11:04.490
We could always fall
back on this number.

00:11:04.490 --> 00:11:06.630
So you could set 0.

00:11:06.630 --> 00:11:10.580
You could try to set some
low number for the maximizer.

00:11:10.580 --> 00:11:12.960
Because if you set a high
number for the maximizer

00:11:12.960 --> 00:11:16.150
as its fail-safe, it's going to
be really snooty and just say,

00:11:16.150 --> 00:11:17.310
oh, I won't take this path.

00:11:17.310 --> 00:11:18.770
I already have a
fail-safe that's

00:11:18.770 --> 00:11:19.970
better than all these paths.

00:11:19.970 --> 00:11:23.460
If you set, like,
100, you have no tree.

00:11:23.460 --> 00:11:26.990
Our default usually, in 6034,
is to set negative infinity

00:11:26.990 --> 00:11:30.340
for alpha or negative some very
large number if you're doing it

00:11:30.340 --> 00:11:32.770
in your lab.

00:11:32.770 --> 00:11:37.670
So if we set negative infinity
as a default for alpha,

00:11:37.670 --> 00:11:41.600
that negative infinity is
basically maximizer loses.

00:11:41.600 --> 00:11:43.020
So the maximizer
goes in thinking,

00:11:43.020 --> 00:11:44.894
oh my god, if I don't
look at this game tree,

00:11:44.894 --> 00:11:46.260
I automatically lose.

00:11:46.260 --> 00:11:51.070
He's willing to take the
first path possibly presented.

00:11:51.070 --> 00:11:52.764
And that's why that
negative infinity

00:11:52.764 --> 00:11:53.930
is a good default for alpha.

00:11:53.930 --> 00:11:56.096
Anyone have a good idea
what a good default for beta

00:11:56.096 --> 00:11:57.710
is, or just remember?

00:11:57.710 --> 00:11:59.090
Positive infinity, that's right.

00:11:59.090 --> 00:12:01.423
Because the minimizer comes
in, and she's like, oh crap,

00:12:01.423 --> 00:12:05.660
the maximizer automatically wins
if I don't look at this node

00:12:05.660 --> 00:12:06.320
here.

00:12:06.320 --> 00:12:08.278
That makes sure the
maximizer and the minimizer

00:12:08.278 --> 00:12:12.240
both are willing to look at the
first path they see every time.

00:12:12.240 --> 00:12:13.635
Because look on this tree.

00:12:13.635 --> 00:12:16.560
If 10 was alpha, the
maximizer would just

00:12:16.560 --> 00:12:19.020
reject out of hand
everything except for P.

00:12:19.020 --> 00:12:20.440
And then we wouldn't
have a tree.

00:12:20.440 --> 00:12:24.750
The maximizer would lose,
because he would be like, hmm,

00:12:24.750 --> 00:12:26.790
this test game is
very interesting.

00:12:26.790 --> 00:12:29.120
However, I have
another option-- pft,

00:12:29.120 --> 00:12:31.380
and then you throw
over the table.

00:12:31.380 --> 00:12:33.976
That's 10 for me, because you
have to pick up the pieces.

00:12:33.976 --> 00:12:34.850
I don't own this set.

00:12:34.850 --> 00:12:36.990
I don't know.

00:12:36.990 --> 00:12:40.440
So that is why we set negative
infinity and positive infinity

00:12:40.440 --> 00:12:42.770
as the default for
alpha and beta.

00:12:42.770 --> 00:12:44.240
So how do alpha
and beta propagate?

00:12:44.240 --> 00:12:45.870
And what do they do?

00:12:45.870 --> 00:12:49.110
The main purpose of alpha
and beta is that, as we said,

00:12:49.110 --> 00:12:52.130
alpha-- let's say we have
some chart of values.

00:12:52.130 --> 00:12:55.700
Alpha, which starts
at negative infinity,

00:12:55.700 --> 00:12:58.935
is the worst that the
maximizer is willing to accept.

00:12:58.935 --> 00:13:01.060
Because they know they can
get that much or better.

00:13:01.060 --> 00:13:03.800
It starts out, that's the
worst thing you can have.

00:13:03.800 --> 00:13:05.470
So it's not a problem.

00:13:05.470 --> 00:13:09.890
Infinity is the highest that the
minimizer is willing to accept.

00:13:09.890 --> 00:13:11.430
That's beta.

00:13:11.430 --> 00:13:13.250
As you go along,
though, the minimizer

00:13:13.250 --> 00:13:14.970
sees, oh, look at that.

00:13:14.970 --> 00:13:18.610
I can guarantee that at
best the maximizer gets 100.

00:13:18.610 --> 00:13:20.700
Haha, beta is now 100.

00:13:20.700 --> 00:13:22.790
The maximizer says, oh yeah?

00:13:22.790 --> 00:13:27.490
Well I can guarantee that the
lowest you can get me to go to

00:13:27.490 --> 00:13:28.280
is 0.

00:13:28.280 --> 00:13:31.330
So it's going to be 0.

00:13:31.330 --> 00:13:36.990
And this keeps going on
until maybe at 6-- note,

00:13:36.990 --> 00:13:38.670
not drawn to scale.

00:13:38.670 --> 00:13:41.940
Maybe at 6, the
maximizer said, haha,

00:13:41.940 --> 00:13:44.030
you can't make me
go lower than 6.

00:13:44.030 --> 00:13:47.650
And the minimizer says, aha, you
can't make me go higher than 6.

00:13:47.650 --> 00:13:50.120
And then 6 is the answer.

00:13:50.120 --> 00:13:56.950
If you ever get to a point where
beta gets lower than alpha,

00:13:56.950 --> 00:14:02.000
or alpha gets lower than beta,
then you just say, screw this.

00:14:02.000 --> 00:14:05.570
I'm not even going to look
at the remaining stuff.

00:14:05.570 --> 00:14:09.870
I'm going to just prune now
and go somewhere else that's

00:14:09.870 --> 00:14:11.780
less pointless than this.

00:14:11.780 --> 00:14:15.220
Because if the alpha gets higher
than the beta, what that's

00:14:15.220 --> 00:14:18.515
saying is the maximizer says,
oh man, look at this, minimizer.

00:14:18.515 --> 00:14:22.450
The lowest you can
make me go is, say, 50.

00:14:22.450 --> 00:14:24.300
And the minimizer
says, that's strange.

00:14:24.300 --> 00:14:28.760
Because the highest that
you can make me go is 40.

00:14:28.760 --> 00:14:32.210
So something's
generally amiss there.

00:14:32.210 --> 00:14:35.220
It usually means that
one of the two of them

00:14:35.220 --> 00:14:37.890
doesn't even want to be
exploring that branch at all.

00:14:37.890 --> 00:14:40.816
So you prune at that point.

00:14:40.816 --> 00:14:43.470
All right, so given that
that's what we're looking for,

00:14:43.470 --> 00:14:46.650
how do we move the alphas and
betas throughout the tree?

00:14:46.650 --> 00:14:48.400
There's a few different
ways to draw them.

00:14:48.400 --> 00:14:52.830
And some of them I
consider to be very busy.

00:14:52.830 --> 00:14:54.930
Probably in recitation
and tutorial

00:14:54.930 --> 00:14:57.980
you will see a way that's
busier and has more numbers.

00:14:57.980 --> 00:15:01.060
Technically, every node has
both an alpha and a beta.

00:15:01.060 --> 00:15:04.560
However, the one that that
node is paying attention to

00:15:04.560 --> 00:15:06.190
is the alpha, if
it's a maximizer,

00:15:06.190 --> 00:15:08.360
and the beta if
it's a minimizer.

00:15:08.360 --> 00:15:12.290
So I generally, for my purposes,
only draw the alpha out

00:15:12.290 --> 00:15:16.330
for the maximizer and only draw
the beta out for the minimizer.

00:15:16.330 --> 00:15:19.742
Very rarely, but it happens,
they'll sometimes ask you,

00:15:19.742 --> 00:15:21.450
well, what's the beta
of this node, which

00:15:21.450 --> 00:15:22.460
is a maximizer node?

00:15:22.460 --> 00:15:24.680
So it's good to know
how it's derived.

00:15:24.680 --> 00:15:27.540
But I think that it wastes
your time to write it out.

00:15:27.540 --> 00:15:28.520
That's my opinion.

00:15:28.520 --> 00:15:29.820
We'll see how it goes.

00:15:29.820 --> 00:15:32.720
So the way that it works, the
way that alpha and beta works,

00:15:32.720 --> 00:15:33.970
is the Snow White principal.

00:15:33.970 --> 00:15:37.100
So does everyone know
the story of Snow White?

00:15:37.100 --> 00:15:38.860
So there's a beautiful princess.

00:15:38.860 --> 00:15:40.696
There's an evil
queen stepmother.

00:15:40.696 --> 00:15:43.070
Mirror mirror on the wall,
who's the fairest of them all,

00:15:43.070 --> 00:15:46.620
finds out that it's
the stepdaughter.

00:15:46.620 --> 00:15:49.130
So much like in the real
world, in Snow White,

00:15:49.130 --> 00:15:52.440
the stepdaughter, Snow White,
had the beauty of her parents.

00:15:52.440 --> 00:15:54.070
She inherited those.

00:15:54.070 --> 00:15:56.560
However, much like in
the real world, maybe

00:15:56.560 --> 00:16:00.810
or perhaps not, the stepmother
had an even better plan.

00:16:00.810 --> 00:16:04.980
She hired a hunter to
sort of hunt Snow White,

00:16:04.980 --> 00:16:07.560
pull out Snow White's
heart, and feed it

00:16:07.560 --> 00:16:09.710
to her so that she
could gain Snow White's

00:16:09.710 --> 00:16:11.590
beauty for herself.

00:16:11.590 --> 00:16:14.900
How many people knew that
version of the story?

00:16:14.900 --> 00:16:15.590
A few people.

00:16:15.590 --> 00:16:17.298
That's the original
version of the story.

00:16:17.298 --> 00:16:18.570
Disney didn't put that in.

00:16:18.570 --> 00:16:19.944
The hunter then
brought the heart

00:16:19.944 --> 00:16:22.250
of a deer, which I think in
Disney the hunter did kill

00:16:22.250 --> 00:16:24.130
a deer arbitrarily,
but it was not

00:16:24.130 --> 00:16:26.260
explained that that's
why he was doing it.

00:16:26.260 --> 00:16:29.540
So in alpha-beta,
it's just like that.

00:16:29.540 --> 00:16:32.760
By which I mean you start
by inheriting the alpha

00:16:32.760 --> 00:16:34.400
and beta of your parents.

00:16:34.400 --> 00:16:38.360
But if you see something that
you like amongst your children,

00:16:38.360 --> 00:16:42.810
you take it for yourself--
the Snow White principle.

00:16:42.810 --> 00:16:44.100
So let's see how that goes.

00:16:44.100 --> 00:16:48.200
Well, I told you guys that
the default alpha was--

00:16:48.200 --> 00:16:49.612
AUDIENCE: Negative infinity.

00:16:49.612 --> 00:16:50.820
PROFESSOR: Negative infinity.

00:16:50.820 --> 00:16:54.300
So here alpha is
negative infinity.

00:16:54.300 --> 00:16:58.310
And I told you that the default
beta was positive infinity.

00:16:58.310 --> 00:17:01.110
We're doing a depth
first search here.

00:17:01.110 --> 00:17:03.590
All right, beta is infinity.

00:17:03.590 --> 00:17:09.099
All right, so we come here to
E. Now, we could put an alpha.

00:17:09.099 --> 00:17:12.140
But I never put
an alpha or a beta

00:17:12.140 --> 00:17:14.250
for one of the terminal nodes.

00:17:14.250 --> 00:17:17.329
Because it can't
really do anything.

00:17:17.329 --> 00:17:19.060
It's just 2.

00:17:19.060 --> 00:17:22.352
So as we go down, we
take the alpha and beta

00:17:22.352 --> 00:17:23.060
from our parents.

00:17:23.060 --> 00:17:25.830
But as we go up to a
parent, if the parent likes

00:17:25.830 --> 00:17:28.450
what it sees in the child,
it takes it instead.

00:17:28.450 --> 00:17:31.440
So I ask you all the
question, would the minimizer

00:17:31.440 --> 00:17:35.490
prefer this 2 that it sees from
its child or its own infinity

00:17:35.490 --> 00:17:36.630
for a beta?

00:17:36.630 --> 00:17:37.390
AUDIENCE: 2

00:17:37.390 --> 00:17:38.790
PROFESSOR: It likes the 2.

00:17:38.790 --> 00:17:40.190
That's absolutely right.

00:17:40.190 --> 00:17:44.060
So 2.

00:17:44.060 --> 00:17:48.575
All right, great, so now we go
down to F. What is F's alpha?

00:17:51.854 --> 00:17:55.938
Who says negative infinity?

00:17:55.938 --> 00:17:58.220
Who says 2?

00:17:58.220 --> 00:18:01.690
No one-- oh, you guys are good.

00:18:01.690 --> 00:18:03.220
It's negative infinity.

00:18:03.220 --> 00:18:06.094
Technically, it also
will have a beta of 2.

00:18:06.094 --> 00:18:07.260
But we're ignoring the beta.

00:18:07.260 --> 00:18:09.890
And the alphas that have
been progressing downward

00:18:09.890 --> 00:18:11.962
from the parents--
negative infinity.

00:18:11.962 --> 00:18:14.170
That's why I called it the
grandfather clause before.

00:18:14.170 --> 00:18:19.280
Because you would often look up
to your grandparent to see what

00:18:19.280 --> 00:18:21.800
your default number is.

00:18:21.800 --> 00:18:23.830
So we get an alpha
of negative infinity.

00:18:23.830 --> 00:18:26.134
We then go down to the K.
It's a static evaluation.

00:18:26.134 --> 00:18:28.550
And now I'm going to start
calling on people individually.

00:18:28.550 --> 00:18:30.450
So hopefully people
paid attention

00:18:30.450 --> 00:18:34.010
to the mob, who
were always correct.

00:18:34.010 --> 00:18:38.520
All right, so we go down
to K. And we see a 3.

00:18:38.520 --> 00:18:40.520
F is a maximizer node.

00:18:40.520 --> 00:18:43.300
So what does F do now?

00:18:43.300 --> 00:18:45.450
AUDIENCE: Switches
its alpha to 3.

00:18:45.450 --> 00:18:48.350
PROFESSOR: Yes, switches
its alpha to 3, great.

00:18:55.430 --> 00:18:59.005
All right, so that's
already quite good.

00:18:59.005 --> 00:19:00.075
It switches alpha to 3.

00:19:00.075 --> 00:19:01.330
It's very happy.

00:19:01.330 --> 00:19:03.526
It's got a 3 here.

00:19:03.526 --> 00:19:06.360
That's a nice value.

00:19:06.360 --> 00:19:16.736
So what does it do
at L, the next node?

00:19:16.736 --> 00:19:18.865
It's gone to K, went
back up to F. Depth

00:19:18.865 --> 00:19:20.740
first search, the next
one would be L, right?

00:19:23.274 --> 00:19:24.149
AUDIENCE: [INAUDIBLE]

00:19:27.376 --> 00:19:32.420
PROFESSOR: Well, technically
F could take L's value of 0

00:19:32.420 --> 00:19:34.690
if it liked it better than 3.

00:19:34.690 --> 00:19:35.590
But it's a maximizer.

00:19:35.590 --> 00:19:37.535
So does it want to take that?

00:19:37.535 --> 00:19:38.410
AUDIENCE: [INAUDIBLE]

00:19:38.410 --> 00:19:40.310
PROFESSOR: OK, that
technically would be correct.

00:19:40.310 --> 00:19:40.893
But I'm sorry.

00:19:40.893 --> 00:19:43.830
I burdened you with
a trick question.

00:19:43.830 --> 00:19:47.180
In fact, we don't
look at L at all.

00:19:51.780 --> 00:19:53.510
Does everyone see that?

00:19:53.510 --> 00:19:54.740
I'll explain.

00:19:54.740 --> 00:19:57.190
The alpha at F has reached 3.

00:19:57.190 --> 00:20:00.700
But the beta at B is 2.

00:20:00.700 --> 00:20:03.600
So B looks down and
says, wait a minute.

00:20:03.600 --> 00:20:06.990
If I go down to F, my
enemy's nuclear option,

00:20:06.990 --> 00:20:10.450
my enemy is the worst it
can be for-- the best it

00:20:10.450 --> 00:20:11.960
can be for me is 3.

00:20:11.960 --> 00:20:14.320
F is trumpeting it around.

00:20:14.320 --> 00:20:16.436
I was thinking of eating
his heart, or whatever,

00:20:16.436 --> 00:20:17.310
but I didn't want to.

00:20:17.310 --> 00:20:19.050
But it's going to be 3.

00:20:19.050 --> 00:20:24.146
It's going to be 3 or
higher down there at F.

00:20:24.146 --> 00:20:25.270
There's no way I want that.

00:20:25.270 --> 00:20:29.310
I already have my own
default escape plan.

00:20:29.310 --> 00:20:30.219
And that's 2.

00:20:30.219 --> 00:20:32.260
That's going to be better
than whatever comes out

00:20:32.260 --> 00:20:35.871
of that horrible F. So screw it.

00:20:35.871 --> 00:20:39.535
And we never look at L.
Does everyone get that?

00:20:39.535 --> 00:20:43.520
That is the main principle
of alpha-beta pruning.

00:20:43.520 --> 00:20:47.100
If you see an alpha that's
higher than the beta above it--

00:20:47.100 --> 00:20:50.020
as I said, if alpha
goes up above the beta--

00:20:50.020 --> 00:20:55.360
or if you see a beta, like
if there's a beta down here,

00:20:55.360 --> 00:20:59.450
and it's lower than the
alpha above it, prune it.

00:20:59.450 --> 00:21:02.450
Stop doing that.

00:21:02.450 --> 00:21:04.270
And the question is, who prunes?

00:21:04.270 --> 00:21:06.840
Who decides that
you don't look at L?

00:21:06.840 --> 00:21:09.560
The person who is
thinking not to look at L

00:21:09.560 --> 00:21:13.460
is always up higher by
at least two levels.

00:21:13.460 --> 00:21:15.670
So up here, B is
saying, hmm, I don't

00:21:15.670 --> 00:21:19.130
want to look at L. Because F
is already so terrible for me

00:21:19.130 --> 00:21:22.890
that it's just beyond belief.

00:21:22.890 --> 00:21:25.920
If this is 100, it might be 100.

00:21:25.920 --> 00:21:29.350
Even if it's lower, I'm
still going to get a three.

00:21:29.350 --> 00:21:33.330
There's a sanity check that
I've written that I sort of came

00:21:33.330 --> 00:21:36.180
up with just in case you're
not sure that you can skip it.

00:21:36.180 --> 00:21:38.060
Because on a lot of
these tests, we ask you,

00:21:38.060 --> 00:21:40.884
which one's do you evaluate,
which ones do you skip, right?

00:21:40.884 --> 00:21:42.675
Or we just say, which
ones do you evaluate,

00:21:42.675 --> 00:21:44.760
and you don't write
the ones that you skip.

00:21:44.760 --> 00:21:48.860
Here's my sanity test to
see if you can skip it.

00:21:48.860 --> 00:21:52.080
Ask yourself, if
that node that I'm

00:21:52.080 --> 00:21:54.040
about to skip contained
a negative infinity

00:21:54.040 --> 00:21:56.550
or some arbitrarily small
number, negative infinity

00:21:56.550 --> 00:22:01.260
being the minimizer wins,
would it change anything?

00:22:01.260 --> 00:22:02.920
Now that I've
answered that, if it

00:22:02.920 --> 00:22:07.350
contained a positive infinity,
would it change anything?

00:22:07.350 --> 00:22:11.820
If the answer is no
both times, then you're

00:22:11.820 --> 00:22:13.760
definitely correct
in pruning it.

00:22:13.760 --> 00:22:14.850
So look at that 0.

00:22:14.850 --> 00:22:16.810
If it was a negative
infinity, minimizer wins,

00:22:16.810 --> 00:22:17.705
what would happen?

00:22:17.705 --> 00:22:20.320
The maximizer would say, I'm
not touching that was a 10 foot

00:22:20.320 --> 00:22:22.370
pole, choosing 3.

00:22:22.370 --> 00:22:26.380
The minimizer would say,
screw that, I'll take E.

00:22:26.380 --> 00:22:28.005
Let's say it was a
positive infinity.

00:22:28.005 --> 00:22:31.075
The maximizer would say,
eureka, holy grain, I win.

00:22:31.075 --> 00:22:33.080
The minimizer would say,
yeah, if I'm a moron,

00:22:33.080 --> 00:22:36.450
and go down to F, and then
would go to E and take 2.

00:22:36.450 --> 00:22:41.640
So no matter what was there,
the minimizer would go to E.

00:22:41.640 --> 00:22:44.100
And you could say, well,
what if it was exactly 2?

00:22:44.100 --> 00:22:46.130
But still the
maximizer would choose

00:22:46.130 --> 00:22:48.520
K. The minimizer would
go to E. So there's

00:22:48.520 --> 00:22:49.680
no reason to go down there.

00:22:49.680 --> 00:22:51.410
We can just prune
it off right now.

00:22:51.410 --> 00:22:54.070
Does everyone
agree, everyone see

00:22:54.070 --> 00:22:55.720
what I'm talking about here?

00:22:55.720 --> 00:23:00.225
Great, so we're now
done with this branch.

00:23:00.225 --> 00:23:01.790
Because beta is 2.

00:23:01.790 --> 00:23:05.232
So now we're up at
old grandpappy A.

00:23:05.232 --> 00:23:06.940
And he has an alpha
of negative infinity.

00:23:06.940 --> 00:23:11.660
Everyone, what will he do?

00:23:11.660 --> 00:23:12.709
He'll take the 2.

00:23:12.709 --> 00:23:14.500
It's better than negative
infinity for him.

00:23:14.500 --> 00:23:15.600
It's not wonderful.

00:23:15.600 --> 00:23:19.670
But certainly anything is
better than an automatic loss.

00:23:19.670 --> 00:23:23.780
All right, now our
highest node is a 2.

00:23:23.780 --> 00:23:27.380
So let's keep that in
mind for our alpha.

00:23:27.380 --> 00:23:29.820
OK, so let's go over here.

00:23:29.820 --> 00:23:32.854
Let's see, so what
will be the value at C?

00:23:32.854 --> 00:23:34.020
What will be the beta value?

00:23:37.366 --> 00:23:40.282
AUDIENCE: [INAUDIBLE]

00:23:42.712 --> 00:23:44.660
PROFESSOR: You go
back to which one?

00:23:44.660 --> 00:23:47.090
To G. I'm not at G yet.

00:23:47.090 --> 00:23:49.800
I'm actually just starting
the middle branch.

00:23:49.800 --> 00:23:52.280
So I'm going to C. And what's
going to be its starting

00:23:52.280 --> 00:23:54.902
beta before I go down?

00:23:54.902 --> 00:23:56.170
AUDIENCE: Infinity.

00:23:56.170 --> 00:23:58.910
PROFESSOR: Infinity, that's
right-- default value.

00:23:58.910 --> 00:24:00.570
It's easier than it seemed.

00:24:00.570 --> 00:24:03.690
All right, so yes, beta
is equal to infinity.

00:24:06.370 --> 00:24:08.090
This should be better erased.

00:24:08.090 --> 00:24:09.570
I think it's confusing people.

00:24:09.570 --> 00:24:14.790
Great, OK, so beta is
equal to infinity at C.

00:24:14.790 --> 00:24:17.110
Now we go down depth
first search to G. What's

00:24:17.110 --> 00:24:18.460
going to be our alpha at G?

00:24:18.460 --> 00:24:19.620
AUDIENCE: Minus infinity.

00:24:19.620 --> 00:24:21.560
PROFESSOR: Ahh,
it would seem so.

00:24:21.560 --> 00:24:26.110
However, take a look up
at the great-grandpappy A.

00:24:26.110 --> 00:24:28.490
It seems to have changed to 2.

00:24:28.490 --> 00:24:29.930
So this time it's 2.

00:24:29.930 --> 00:24:31.680
Why is it 2 instead
of negative infinity?

00:24:31.680 --> 00:24:34.873
Why can we let A be so noxious
and not start with saying,

00:24:34.873 --> 00:24:36.710
oh, I automatically lose?

00:24:36.710 --> 00:24:40.040
Well, A knows that no
matter how awful things get

00:24:40.040 --> 00:24:42.680
in that middle branch,
he can just say,

00:24:42.680 --> 00:24:43.930
screw the whole middle branch.

00:24:43.930 --> 00:24:45.110
I'm going to B.

00:24:45.110 --> 00:24:47.796
That's something that
the minimizer can't do.

00:24:47.796 --> 00:24:49.920
And we have to start at
infinity for the minimizer.

00:24:49.920 --> 00:24:51.140
But the maximizer can.

00:24:51.140 --> 00:24:52.790
Because he has the
choice at the top.

00:24:52.790 --> 00:24:53.850
Does everyone see that?

00:24:53.850 --> 00:24:56.440
He can just say, oh, I'm
not even going to C. Yeah,

00:24:56.440 --> 00:24:57.330
shows you.

00:24:57.330 --> 00:24:59.320
I'm going to A and taking the 2.

00:24:59.320 --> 00:25:03.640
So therefore alpha
is actually 2 at G.

00:25:03.640 --> 00:25:06.500
All right, great, so
we've got an alpha that's

00:25:06.500 --> 00:25:10.790
2 at G. We're going to go
down to M. It's a minimizer.

00:25:10.790 --> 00:25:14.407
All right, what's going
to be our beta value at M?

00:25:14.407 --> 00:25:15.282
AUDIENCE: [INAUDIBLE]

00:25:19.230 --> 00:25:21.325
PROFESSOR: Or which is
the beta default, minus

00:25:21.325 --> 00:25:22.200
or positive infinity?

00:25:22.200 --> 00:25:24.554
What would be the minimizer?

00:25:24.554 --> 00:25:25.345
AUDIENCE: Positive.

00:25:25.345 --> 00:25:27.180
PROFESSOR: Positive
infinity, that's right.

00:25:27.180 --> 00:25:29.250
M is going to be a
positive infinity for beta.

00:25:29.250 --> 00:25:34.670
Again, it picks it
up from C. Great,

00:25:34.670 --> 00:25:39.030
now we get to some
actual values.

00:25:39.030 --> 00:25:41.390
So we're at some actual values.

00:25:41.390 --> 00:25:45.520
We are at Q. So
what's going to happen

00:25:45.520 --> 00:25:47.230
at M when M sees that Q is 1?

00:25:53.431 --> 00:25:55.040
AUDIENCE: [INAUDIBLE]

00:25:55.040 --> 00:25:56.040
PROFESSOR: What is beta?

00:25:56.040 --> 00:25:56.371
It says infinity.

00:25:56.371 --> 00:25:57.890
I'm sorry, it's hard to read.

00:25:57.890 --> 00:25:59.486
Beta is infinity at M.

00:25:59.486 --> 00:26:01.470
AUDIENCE: OK, so it's
going to minimize, right?

00:26:01.470 --> 00:26:05.001
So it's going to be
like, OK, [INAUDIBLE].

00:26:05.001 --> 00:26:06.000
PROFESSOR: That's right.

00:26:06.000 --> 00:26:08.270
So they're going
to put beta to 1.

00:26:08.270 --> 00:26:16.250
Because it sees Q. Great,
so my next question is,

00:26:16.250 --> 00:26:19.124
what's going to happen at R?

00:26:19.124 --> 00:26:22.052
AUDIENCE: [INAUDIBLE]

00:26:28.030 --> 00:26:30.010
PROFESSOR: Very smart.

00:26:30.010 --> 00:26:31.397
You've detected my trap.

00:26:31.397 --> 00:26:32.855
The question is,
does it look at R?

00:26:32.855 --> 00:26:35.142
The answer is, no.

00:26:35.142 --> 00:26:37.100
It doesn't look at R.
Why doesn't it look at R?

00:26:37.100 --> 00:26:39.020
Does everyone see?

00:26:39.020 --> 00:26:42.330
Yeah, alpha is now greater
than the beta below it.

00:26:42.330 --> 00:26:43.917
Beta has gotten
lower than alpha.

00:26:43.917 --> 00:26:46.000
This is the same thing I
was talking about before,

00:26:46.000 --> 00:26:48.090
when we figured out that
the alpha here is 2.

00:26:48.090 --> 00:26:52.470
The maximizer says,
wait a minute.

00:26:52.470 --> 00:26:55.740
The maximizer G says, if I go
to M, the best I'm getting out

00:26:55.740 --> 00:26:56.759
of this is 1.

00:26:56.759 --> 00:26:58.300
Because if this is
negative infinity,

00:26:58.300 --> 00:26:59.680
the minimizer will choose it.

00:26:59.680 --> 00:27:01.555
If this is positive
infinity, he'll choose 1.

00:27:01.555 --> 00:27:04.237
The best I'm going to
get out of here is 1.

00:27:04.237 --> 00:27:06.320
If that's the case, I might
as well have just gone

00:27:06.320 --> 00:27:09.600
to B and not even gone to C.
So I'm not going to go to M.

00:27:09.600 --> 00:27:10.440
I'll go to N, maybe.

00:27:10.440 --> 00:27:13.370
Maybe N is better.

00:27:13.370 --> 00:27:15.300
Does everyone see that?

00:27:15.300 --> 00:27:20.270
Great, so let's say that
the maximizer does go to N.

00:27:20.270 --> 00:27:23.379
So what's going to
happen with this alpha?

00:27:23.379 --> 00:27:24.800
AUDIENCE: [INAUDIBLE]

00:27:24.800 --> 00:27:26.640
PROFESSOR: That's right,
it's going to be 7.

00:27:26.640 --> 00:27:28.080
7 is better than 2.

00:27:28.080 --> 00:27:30.960
And the maximizer has
control to get to that seven,

00:27:30.960 --> 00:27:36.940
at least if it gets to G. All
right, now the minimizer at C--

00:27:36.940 --> 00:27:38.580
we'll do everyone this time.

00:27:38.580 --> 00:27:43.798
The minimizer at C, seeing that
7, what does the minimizer do?

00:27:43.798 --> 00:27:44.298
Anyone?

00:27:48.200 --> 00:27:49.210
So it sees the 7.

00:27:49.210 --> 00:27:50.680
What does it do to its beta?

00:27:50.680 --> 00:27:55.330
It takes the 7-- better
than infinity, anyway.

00:27:55.330 --> 00:27:58.290
And yeah, then it checks H.
And everybody, again, what

00:27:58.290 --> 00:28:00.100
happens at H?

00:28:00.100 --> 00:28:00.970
It takes the 6.

00:28:00.970 --> 00:28:01.865
It's lower than 7.

00:28:04.730 --> 00:28:07.747
All right, now we'll
go back to having

00:28:07.747 --> 00:28:08.830
people do it on their own.

00:28:08.830 --> 00:28:10.246
Well, all the way
back to the top,

00:28:10.246 --> 00:28:13.216
what does A do when it
sees the 6 coming out of C?

00:28:13.216 --> 00:28:15.150
AUDIENCE: Changes to 6.

00:28:15.150 --> 00:28:17.330
PROFESSOR: Changes
to 6, that's right.

00:28:17.330 --> 00:28:18.910
Alpha equals 6.

00:28:18.910 --> 00:28:24.620
Great-- homestretch,
people, homestretch.

00:28:24.620 --> 00:28:31.650
So the minimizer, everyone,
has a beta of infinity.

00:28:31.650 --> 00:28:35.070
And if I wasn't a static node,
it would have an alpha of 6.

00:28:35.070 --> 00:28:36.090
But it is a static node.

00:28:36.090 --> 00:28:38.570
So it just has a value of 1.

00:28:38.570 --> 00:28:43.380
So since it has a value of 1,
everyone, the beta becomes 1.

00:28:43.380 --> 00:28:45.264
And what next, everyone?

00:28:45.264 --> 00:28:45.930
AUDIENCE: Prune.

00:28:45.930 --> 00:28:49.960
PROFESSOR: Prune, that's right.

00:28:49.960 --> 00:28:51.110
Why prune?

00:28:51.110 --> 00:28:54.650
Well, this time it's A
himself who can prune.

00:28:54.650 --> 00:28:56.723
A says, well darn,
if I go to D, I'm

00:28:56.723 --> 00:28:59.360
going to get 1 or something
even worse than 1.

00:28:59.360 --> 00:29:02.550
I might as well take
my 6 while I have it,

00:29:02.550 --> 00:29:04.875
prune all the rest
all the way down.

00:29:09.210 --> 00:29:10.620
Everyone see that?

00:29:10.620 --> 00:29:12.710
Everyone cool with that?

00:29:12.710 --> 00:29:16.060
It's not too bad if you
take it one step at a time.

00:29:16.060 --> 00:29:18.410
We did it.

00:29:18.410 --> 00:29:21.966
Our question is, which nodes
are evaluated in order?

00:29:21.966 --> 00:29:35.170
Our answer is, everyone-- E, K,
Q, N, H, I. OK, not so obvious,

00:29:35.170 --> 00:29:35.670
I guess.

00:29:35.670 --> 00:29:36.980
A few people followed me.

00:29:36.980 --> 00:29:40.590
But it is E, K, Q, N, H, I.
It's just depth first order.

00:29:40.590 --> 00:29:43.220
And we pruned some of them away.

00:29:43.220 --> 00:29:47.260
Great, so that is alpha-beta.

00:29:47.260 --> 00:29:49.470
Any questions about that
before I give some questions

00:29:49.470 --> 00:29:52.022
about progressive deepening?

00:29:52.022 --> 00:29:53.230
All right, we've got a bunch.

00:29:53.230 --> 00:29:55.182
So first question.

00:29:55.182 --> 00:30:02.480
AUDIENCE: [INAUDIBLE]
nodes like F, B, C, and D?

00:30:02.480 --> 00:30:04.190
PROFESSOR: The
question is, when asked

00:30:04.190 --> 00:30:07.900
for the order of evaluation,
are we excluding F, B, C, and D?

00:30:07.900 --> 00:30:11.250
The answer is we're talking
about here static evaluation.

00:30:11.250 --> 00:30:14.720
The static evaluator is a
very important and interesting

00:30:14.720 --> 00:30:15.400
function.

00:30:15.400 --> 00:30:18.230
And I'll get back to something
a few students have asked me

00:30:18.230 --> 00:30:21.484
about the static evaluator later
and try to explain what it is.

00:30:21.484 --> 00:30:23.650
It's basically the thing
that pops out those numbers

00:30:23.650 --> 00:30:25.015
at the bottom of the leaves.

00:30:25.015 --> 00:30:26.765
So when we ask, what
is the order of nodes

00:30:26.765 --> 00:30:31.510
that were statically
evaluated, we mean leaves only.

00:30:31.510 --> 00:30:32.580
That's a good question.

00:30:32.580 --> 00:30:33.620
Any other questions?

00:30:33.620 --> 00:30:35.430
Let's see, there was
one up here before.

00:30:35.430 --> 00:30:36.170
But it's gone.

00:30:36.170 --> 00:30:37.885
It might have been the same one.

00:30:37.885 --> 00:30:38.384
Question?

00:30:38.384 --> 00:30:39.717
AUDIENCE: So a similar question.

00:30:39.717 --> 00:30:42.578
When you say, static nodes,
that just means the leaf nodes?

00:30:42.578 --> 00:30:43.750
PROFESSOR: Means the
leaf nodes, that's right.

00:30:43.750 --> 00:30:46.041
The question is, does static
nodes mean the leaf nodes.

00:30:46.041 --> 00:30:46.903
The answer is yes.

00:30:46.903 --> 00:30:48.319
AUDIENCE: And so
static evaluation

00:30:48.319 --> 00:30:51.737
is when you compare the value
of a static node to something?

00:30:51.737 --> 00:30:53.570
PROFESSOR: Static
evaluation is when you get

00:30:53.570 --> 00:30:55.180
that number, the static node.

00:30:55.180 --> 00:30:56.480
Let me explain.

00:30:56.480 --> 00:30:59.140
Unless someone else has another
question about alpha-beta,

00:30:59.140 --> 00:31:00.500
let me explain static values.

00:31:00.500 --> 00:31:02.030
Because I was about to do that.

00:31:02.030 --> 00:31:03.571
There is a question
about alpha-beta.

00:31:03.571 --> 00:31:06.326
I'll come back to both of
yours after I answer this.

00:31:06.326 --> 00:31:09.437
AUDIENCE: You were
mentioning [INAUDIBLE].

00:31:09.437 --> 00:31:11.385
And I'm a little bit confused.

00:31:11.385 --> 00:31:13.576
If you're looking at
one node, and you're

00:31:13.576 --> 00:31:16.255
seeing either grab the
value from the grandparent

00:31:16.255 --> 00:31:18.203
or grab it from the--

00:31:18.203 --> 00:31:21.134
PROFESSOR: So it always
starts-- the question is, what

00:31:21.134 --> 00:31:22.300
is the Snow White principle?

00:31:22.300 --> 00:31:23.380
How does it work?

00:31:23.380 --> 00:31:26.760
Every node always
starts off with taking

00:31:26.760 --> 00:31:29.865
the value of the same
type, alpha or beta,

00:31:29.865 --> 00:31:30.740
from its grandparent.

00:31:30.740 --> 00:31:33.010
It always starts that way.

00:31:33.010 --> 00:31:34.427
Now, you say, why
the grandparent?

00:31:34.427 --> 00:31:35.926
Wouldn't it take
it from the parent?

00:31:35.926 --> 00:31:37.050
It actually does.

00:31:37.050 --> 00:31:39.430
But I'm not drawing out the
alphas at all the minimizer

00:31:39.430 --> 00:31:39.700
levels.

00:31:39.700 --> 00:31:40.991
Because they don't do anything.

00:31:40.991 --> 00:31:44.200
They're only even there
to pass them down.

00:31:44.200 --> 00:31:48.110
So all of the values pass
down, down, down, down, down

00:31:48.110 --> 00:31:49.050
to begin.

00:31:49.050 --> 00:31:55.390
Every node, in fact, starts
off with its grandparents

00:31:55.390 --> 00:31:57.920
with its parents' values, OK?

00:31:57.920 --> 00:32:00.730
But then when the
node sees a child,

00:32:00.730 --> 00:32:02.780
it's completely done evaluating.

00:32:02.780 --> 00:32:05.360
It's finished.

00:32:05.360 --> 00:32:08.380
It can't be in the process.

00:32:08.380 --> 00:32:13.550
Let's say C. When C sees
that G is completely

00:32:13.550 --> 00:32:15.780
done with all of
its sub-branches

00:32:15.780 --> 00:32:18.760
and is ready to return
a value, or if it's just

00:32:18.760 --> 00:32:22.120
a static evaluation, then it's
automatically completely done.

00:32:22.120 --> 00:32:25.020
Because it has no children.

00:32:25.020 --> 00:32:29.550
A static value like K of 3 is
automatically completely done.

00:32:29.550 --> 00:32:30.830
It's got a 3.

00:32:30.830 --> 00:32:33.360
Similarly, when we came
back to G after going to N,

00:32:33.360 --> 00:32:36.140
and we knew that the value was
7, that was completely done.

00:32:36.140 --> 00:32:37.730
The value was definitely 7.

00:32:37.730 --> 00:32:39.480
There was no other
possibilities.

00:32:39.480 --> 00:32:40.830
AUDIENCE: That's after looking
at the children, right?

00:32:40.830 --> 00:32:41.500
PROFESSOR: Yes.

00:32:41.500 --> 00:32:44.630
So once you're done with
all the children of G,

00:32:44.630 --> 00:32:46.250
then G comes up and
says, guess what?

00:32:46.250 --> 00:32:47.409
Guess what, guys?

00:32:47.409 --> 00:32:48.950
So technically before
that, you would

00:32:48.950 --> 00:32:53.210
have said that G's alpha is
greater than or equal to 1

00:32:53.210 --> 00:32:55.950
when we looked at Q. And then
we looked at M. We'd say,

00:32:55.950 --> 00:32:57.640
it's equal exactly to 7.

00:32:57.640 --> 00:32:58.890
We're done here.

00:32:58.890 --> 00:33:02.170
And then at that point,
when it's fresh and ripe

00:33:02.170 --> 00:33:04.890
and has all of its highest
value or its best value,

00:33:04.890 --> 00:33:08.100
that's when the parent can eat
its heart and gain that value

00:33:08.100 --> 00:33:08.980
itself.

00:33:08.980 --> 00:33:12.340
So that's when C says,
for instance, oh man,

00:33:12.340 --> 00:33:14.550
I have an infinity.

00:33:14.550 --> 00:33:16.060
I really like that 7 better.

00:33:16.060 --> 00:33:17.390
And it takes the 7.

00:33:17.390 --> 00:33:19.840
But then it saw H. And it
said, oh man, that's a 6.

00:33:19.840 --> 00:33:20.980
That's even better than 7.

00:33:20.980 --> 00:33:21.765
So it took the 6.

00:33:21.765 --> 00:33:24.510
AUDIENCE: So shouldn't
the alpha take 7 then?

00:33:24.510 --> 00:33:25.780
PROFESSOR: So alpha takes 6.

00:33:25.780 --> 00:33:27.300
Because C is a minimizer.

00:33:27.300 --> 00:33:29.960
C took the 7 from
G, but then right

00:33:29.960 --> 00:33:32.810
after that C saw
H and took the 6.

00:33:32.810 --> 00:33:35.880
Because 6 is even lower than 7.

00:33:35.880 --> 00:33:38.160
And then alpha took the 6.

00:33:38.160 --> 00:33:40.260
Because 6 was higher than 2.

00:33:40.260 --> 00:33:42.824
AUDIENCE: So it's not going
to look below the branch?

00:33:42.824 --> 00:33:45.240
PROFESSOR: Yeah, the problem
is that the maximizer doesn't

00:33:45.240 --> 00:33:46.490
have control there.

00:33:46.490 --> 00:33:48.464
The minimizer has
got control at C.

00:33:48.464 --> 00:33:49.880
And the minimizer
is going to make

00:33:49.880 --> 00:33:52.020
sure it's as low as possible.

00:33:52.020 --> 00:33:56.470
The maximizer at A, his only
control, or her only control,

00:33:56.470 --> 00:33:59.460
is the ability to send
either way to B or C

00:33:59.460 --> 00:34:02.346
or D. And then at
that point, at C,

00:34:02.346 --> 00:34:04.345
the minimizer gets to
choose if we go to G or H.

00:34:04.345 --> 00:34:07.300
And it's never going to choose
G. Because G is higher than H.

00:34:07.300 --> 00:34:09.829
All right, awesome, was
there another question?

00:34:09.829 --> 00:34:12.830
All right, let's go back
to static evaluations.

00:34:12.830 --> 00:34:16.139
When I first took this class,
I had some weird thoughts

00:34:16.139 --> 00:34:17.139
about static evolutions.

00:34:17.139 --> 00:34:18.739
I heard some
students ask me this.

00:34:18.739 --> 00:34:21.475
I almost got a question about
it onto one of the tests,

00:34:21.475 --> 00:34:23.600
but it was edited to some
other weird question that

00:34:23.600 --> 00:34:25.451
was m to the b to the
d minus 1 or something

00:34:25.451 --> 00:34:26.659
like that at the last minute.

00:34:26.659 --> 00:34:28.909
So I'm going to pose you
guys the actual question that

00:34:28.909 --> 00:34:31.520
would have been on one
of the older test, which

00:34:31.520 --> 00:34:32.790
is the following.

00:34:32.790 --> 00:34:34.873
I had a student who came
to me and said, you know,

00:34:34.873 --> 00:34:37.489
[INAUDIBLE], when we do this
alpha-beta pruning, and all

00:34:37.489 --> 00:34:40.560
this other stuff, we're trying
to assume that we're really

00:34:40.560 --> 00:34:42.870
saving that much
time by getting rid

00:34:42.870 --> 00:34:44.361
of a few static evaluations.

00:34:44.361 --> 00:34:46.110
In fact, when we do
progressive deepening,

00:34:46.110 --> 00:34:48.401
we're always just counting,
how many static evaluations

00:34:48.401 --> 00:34:49.290
do we have to do?

00:34:49.290 --> 00:34:51.586
And he said, I look at
these static evaluations.

00:34:51.586 --> 00:34:52.710
And there's just a 3 there.

00:34:52.710 --> 00:34:56.520
It takes no time to do
the static evaluation.

00:34:56.520 --> 00:34:57.890
It's on the board.

00:34:57.890 --> 00:34:59.920
It takes much longer
to do the alpha-beta.

00:34:59.920 --> 00:35:02.770
It's faster by far
to not do alpha-beta.

00:35:02.770 --> 00:35:04.680
So I then tried to
explain to that student.

00:35:04.680 --> 00:35:07.050
I said, OK, we need
to be clear about what

00:35:07.050 --> 00:35:08.340
static evaluations are.

00:35:08.340 --> 00:35:09.590
You guys get it easy.

00:35:09.590 --> 00:35:11.657
We put these numbers
on the board.

00:35:11.657 --> 00:35:13.240
A static evaluation--
let's say you're

00:35:13.240 --> 00:35:17.010
playing a game like chess.

00:35:17.010 --> 00:35:19.050
Static evaluation
takes a long time.

00:35:19.050 --> 00:35:21.910
When I was in 6170,
Java [INAUDIBLE],

00:35:21.910 --> 00:35:24.150
the class that used to
exist, we had a program

00:35:24.150 --> 00:35:28.440
called Anti-Chess where I used
my 6034 skills to write the AI.

00:35:28.440 --> 00:35:31.890
And the static evaluator
took a long time.

00:35:31.890 --> 00:35:32.970
And we were timed.

00:35:32.970 --> 00:35:34.970
So getting the static
evaluator faster,

00:35:34.970 --> 00:35:36.602
that was the most
important thing.

00:35:36.602 --> 00:35:37.810
Why does it take a long time?

00:35:37.810 --> 00:35:39.875
Well, the static
evaluator is an evaluation

00:35:39.875 --> 00:35:43.730
of the board position,
the state of the game,

00:35:43.730 --> 00:35:45.519
at a snapshot of time.

00:35:45.519 --> 00:35:48.060
And that's not as easy as just
saying, oh, here's the answer.

00:35:48.060 --> 00:35:51.500
Because in chess,
first of all, not only

00:35:51.500 --> 00:35:53.780
did I have to look at
how many pieces I had,

00:35:53.780 --> 00:35:56.520
what areas that I controlled.

00:35:56.520 --> 00:35:58.154
Also-- well, it was anti-chess.

00:35:58.154 --> 00:35:59.320
But that's not withstanding.

00:35:59.320 --> 00:36:01.110
Let's pretend it's
regular chess.

00:36:01.110 --> 00:36:03.900
I also had to look, if
it was in regular chess--

00:36:03.900 --> 00:36:05.650
and I still had to do
this in anti-chess--

00:36:05.650 --> 00:36:06.850
if my king was in check.

00:36:06.850 --> 00:36:08.350
And what that meant
is I had to look

00:36:08.350 --> 00:36:11.040
at all of my opponent's
moves, possible moves,

00:36:11.040 --> 00:36:13.120
to see if anyone of
them could take my king.

00:36:13.120 --> 00:36:15.921
Because in regular chess,
it's illegal to put your king

00:36:15.921 --> 00:36:16.420
into check.

00:36:16.420 --> 00:36:18.830
So you better not
even allow that move.

00:36:18.830 --> 00:36:20.500
And regardless,
getting into checkmate

00:36:20.500 --> 00:36:22.670
is negative infinity for you.

00:36:22.670 --> 00:36:27.100
So it takes a really long
time to do static evaluations,

00:36:27.100 --> 00:36:29.380
at least good ones, usually.

00:36:29.380 --> 00:36:30.400
You want to avoid them.

00:36:30.400 --> 00:36:32.740
Because they're not just
some number on the page.

00:36:32.740 --> 00:36:34.910
They are some function
you wrote that does

00:36:34.910 --> 00:36:38.230
a very careful analysis of the
state of the game and says,

00:36:38.230 --> 00:36:41.770
I'm good to heuristically
guess that my value is

00:36:41.770 --> 00:36:45.580
pi, or some other
number, and then rates

00:36:45.580 --> 00:36:47.060
that compared to other states.

00:36:47.060 --> 00:36:49.530
Does that make
sense to everyone?

00:36:49.530 --> 00:36:51.790
So the answer to the
hypothetical question

00:36:51.790 --> 00:36:53.628
that might have been
on the old test, when

00:36:53.628 --> 00:36:56.086
the person said, I've got this
great idea where you do tons

00:36:56.086 --> 00:36:57.544
of static evaluation,
and you don't

00:36:57.544 --> 00:37:00.620
have to do this long
alpha-beta, is, don't do that.

00:37:00.620 --> 00:37:04.805
The static evaluations
actually take a long time.

00:37:04.805 --> 00:37:06.680
Does that clear it up
for people who asked me

00:37:06.680 --> 00:37:11.130
before about what is a static
evaluation, why are the leaf

00:37:11.130 --> 00:37:12.030
nodes called static?

00:37:14.730 --> 00:37:17.550
And you might ask, why are
some of these static just

00:37:17.550 --> 00:37:19.140
arbitrarily?

00:37:19.140 --> 00:37:23.030
The answer is, when you're
running out of time to expand

00:37:23.030 --> 00:37:26.270
deeper, and you just need to
stop that stage of the game--

00:37:26.270 --> 00:37:27.744
maybe it's just
getting too hairy,

00:37:27.744 --> 00:37:29.160
maybe it's spreading
out too much,

00:37:29.160 --> 00:37:30.760
you have some
heuristic that says,

00:37:30.760 --> 00:37:33.500
this is where I
stop for now-- it's

00:37:33.500 --> 00:37:35.740
a heuristic guess of the value.

00:37:35.740 --> 00:37:37.990
It's kind of like those
heuristic values in the search

00:37:37.990 --> 00:37:38.330
tree.

00:37:38.330 --> 00:37:39.704
It's a guess of
how much work you

00:37:39.704 --> 00:37:41.340
have left to get to the goal.

00:37:41.340 --> 00:37:43.720
Here, you say, well, I
wish I could go deeper.

00:37:43.720 --> 00:37:45.100
But I just don't have the time.

00:37:45.100 --> 00:37:48.250
So here's how I think
I'm doing at this level.

00:37:48.250 --> 00:37:49.359
It's not always right.

00:37:49.359 --> 00:37:51.150
And that's going to
lead us into the answer

00:37:51.150 --> 00:37:53.210
to one of the questions
about progressive deepening.

00:37:53.210 --> 00:37:54.876
So I'll put up the
progressive deepening

00:37:54.876 --> 00:37:56.050
question really quickly.

00:37:56.050 --> 00:38:00.610
So the question is this.

00:38:00.610 --> 00:38:02.610
Let me see, this is
a maximizer-- yes.

00:38:02.610 --> 00:38:10.515
Suppose that we do progressive
deepening on the tree that

00:38:10.515 --> 00:38:11.600
is only two levels deep.

00:38:11.600 --> 00:38:13.620
What is progressive deepening
in a nutshell if you don't

00:38:13.620 --> 00:38:14.930
remember from the lecture?

00:38:14.930 --> 00:38:17.890
The idea is this.

00:38:17.890 --> 00:38:20.080
In this tree, it doesn't work.

00:38:20.080 --> 00:38:22.550
But in trees that actually
branch like 2 to the n,

00:38:22.550 --> 00:38:26.280
it doesn't take that much time
to do some of the top levels

00:38:26.280 --> 00:38:29.240
first and then move on
to the bottom levels.

00:38:29.240 --> 00:38:31.250
Just do them one at a time.

00:38:31.250 --> 00:38:33.840
So let's say we only did it
up through J. We only did

00:38:33.840 --> 00:38:35.890
the top two levels of the tree.

00:38:35.890 --> 00:38:38.690
We'd like to reorder the
tree so that alpha-beta

00:38:38.690 --> 00:38:43.250
can prune as much as it
possibly can, at least we hope.

00:38:43.250 --> 00:38:47.240
So let's pretend that we
had a psychic awesome genius

00:38:47.240 --> 00:38:50.520
friend who told us that the
static values when we went up

00:38:50.520 --> 00:38:52.680
to two levels-- remember,
when we go to two levels,

00:38:52.680 --> 00:38:55.440
F, G, and J have to get
a static value, right?

00:38:55.440 --> 00:38:56.750
Because we're not going down.

00:38:56.750 --> 00:38:58.180
We do a static evaluation.

00:38:58.180 --> 00:39:02.410
They get the exact correct
numbers-- 3, 7, and 20.

00:39:02.410 --> 00:39:03.573
Genius, brilliant.

00:39:03.573 --> 00:39:07.500
All right, so if
that happens, what

00:39:07.500 --> 00:39:10.200
is the best way that we
could reorder that tree?

00:39:10.200 --> 00:39:18.880
Oh yeah, so it's A, B, C, D with
values of 2, 3, 7, 6, 1, 20.

00:39:18.880 --> 00:39:21.880
I'll draw that.

00:39:21.880 --> 00:39:23.390
This is the non-reordered tree.

00:39:29.890 --> 00:39:41.410
Let's see, so it's
2, 3, 7, 6, 1, 20.

00:39:41.410 --> 00:39:43.584
So what's the best
way to reorder?

00:39:43.584 --> 00:39:45.250
Well, first of all,
does anyone remember

00:39:45.250 --> 00:39:49.300
what Patrick said when he talked
about progressive deepening?

00:39:49.300 --> 00:39:53.800
Usually no one does, so
don't worry about it.

00:39:53.800 --> 00:39:55.880
Because at that time
you guys didn't think,

00:39:55.880 --> 00:39:57.390
oh, I have to do
this for the quiz.

00:39:57.390 --> 00:39:58.987
You were just
thinking, oh man, we've

00:39:58.987 --> 00:40:01.070
already heard alpha-beta
and all this other stuff.

00:40:01.070 --> 00:40:02.570
And this is just a small fact.

00:40:02.570 --> 00:40:04.650
But it's a very important fact.

00:40:04.650 --> 00:40:06.720
And now you know you have
to do it for the quiz.

00:40:06.720 --> 00:40:08.600
So you're probably
going to remember it.

00:40:08.600 --> 00:40:13.510
The way you do it is you
try to guess, and you say,

00:40:13.510 --> 00:40:16.030
which one of these is
going to be a winner?

00:40:16.030 --> 00:40:19.530
Whichever one I think is going
to be a winner at that level,

00:40:19.530 --> 00:40:21.360
I put first.

00:40:21.360 --> 00:40:22.500
Why is that the case?

00:40:22.500 --> 00:40:27.110
Well, something interesting
you may have noticed here--

00:40:27.110 --> 00:40:30.590
whenever you have a winner,
like the middle node,

00:40:30.590 --> 00:40:34.060
or whenever you have
whatever is the current best

00:40:34.060 --> 00:40:36.790
for your alpha, you sort
of have to explore out

00:40:36.790 --> 00:40:39.160
a lot of that area.

00:40:39.160 --> 00:40:42.390
Like for instance, the left
node was our current best at 2.

00:40:42.390 --> 00:40:44.250
The middle branch
was our current best,

00:40:44.250 --> 00:40:45.130
at that time was 6.

00:40:45.130 --> 00:40:46.382
It was the total best.

00:40:46.382 --> 00:40:48.090
We had to explore a
good number of nodes.

00:40:48.090 --> 00:40:50.370
But on the right, we
just saw, oh, there's 1.

00:40:50.370 --> 00:40:50.930
We're done.

00:40:50.930 --> 00:40:53.070
We cut everything off.

00:40:53.070 --> 00:40:55.150
In other words, the
branch that turns out

00:40:55.150 --> 00:40:57.052
to be the one that
you take, you have

00:40:57.052 --> 00:40:58.760
to do a pretty good
amount of exploration

00:40:58.760 --> 00:41:00.554
to prove that it's
the right one.

00:41:00.554 --> 00:41:01.970
Whereas if it's
the wrong one, you

00:41:01.970 --> 00:41:05.320
can sometimes with just one
node say, this is wrong, done.

00:41:05.320 --> 00:41:07.100
So therefore, if the
one that turns out

00:41:07.100 --> 00:41:10.510
to be the eventual
winner is first of all,

00:41:10.510 --> 00:41:13.290
then it's really easy to
reject all the other branches.

00:41:13.290 --> 00:41:16.490
Do people see that sort of
conceptually a little bit,

00:41:16.490 --> 00:41:19.250
that if you get the
best node right away,

00:41:19.250 --> 00:41:22.390
you can just reject all the
wrong ones pretty quickly?

00:41:22.390 --> 00:41:23.560
That's our goal.

00:41:23.560 --> 00:41:25.970
So how can we, quote, "get
the right one," the best one

00:41:25.970 --> 00:41:27.040
right away?

00:41:27.040 --> 00:41:30.050
Well, here's how we do it.

00:41:30.050 --> 00:41:33.590
Let's say we're at B. Which one
is the minimizer likely to pick

00:41:33.590 --> 00:41:35.800
assuming that our
heuristic is good

00:41:35.800 --> 00:41:38.920
and that these guesses are
pretty much close to the truth?

00:41:38.920 --> 00:41:41.261
It turns out they're perfect,
so this is going to work.

00:41:41.261 --> 00:41:42.760
So which one will
the minimizer pick

00:41:42.760 --> 00:41:44.801
if it has to choose between
E and F, do we think?

00:41:44.801 --> 00:41:45.534
AUDIENCE: E.

00:41:45.534 --> 00:41:46.450
PROFESSOR: E, perfect.

00:41:46.450 --> 00:41:48.981
Which one will it
pick between G and H?

00:41:48.981 --> 00:41:49.481
AUDIENCE: H.

00:41:49.481 --> 00:41:51.689
PROFESSOR: H. Which one will
it pick between I and J?

00:41:51.689 --> 00:41:52.470
AUDIENCE: I.

00:41:52.470 --> 00:41:54.660
PROFESSOR: OK, so
what we're saying

00:41:54.660 --> 00:41:56.790
is we think it's
going to pick E.

00:41:56.790 --> 00:41:59.576
We think it's going to pick H.
We think it's going to pick I.

00:41:59.576 --> 00:42:02.830
So first of all, we should
put E before F, H before G,

00:42:02.830 --> 00:42:06.490
and I before J. Because we think
it's going to pick those first.

00:42:06.490 --> 00:42:10.190
Those are probably our best ones
to invalidate a poor branch.

00:42:10.190 --> 00:42:12.360
So now between 2,
6, and 1, which

00:42:12.360 --> 00:42:15.110
is what we think we're going
to get, which one do we think

00:42:15.110 --> 00:42:16.691
the maximizer is going to take?

00:42:16.691 --> 00:42:17.190
AUDIENCE: 6.

00:42:17.190 --> 00:42:18.050
PROFESSOR: 6.

00:42:18.050 --> 00:42:21.940
Then if it couldn't take 6, what
would be its next best choice?

00:42:21.940 --> 00:42:23.690
2, then 1.

00:42:23.690 --> 00:42:27.120
That's just our
order-- simple as that.

00:42:27.120 --> 00:42:28.630
It couldn't be
anything easier that

00:42:28.630 --> 00:42:31.130
evolves really complex trees,
a huge number of numbers,

00:42:31.130 --> 00:42:33.200
and reordering those trees.

00:42:33.200 --> 00:42:42.905
So C-- you guys told me C, B,
D. You told me C, B, D, I think?

00:42:42.905 --> 00:42:44.780
Yeah, those are the ones
the maximizer likes.

00:42:44.780 --> 00:42:49.740
And then the ones the minimizer
likes you told me was H,

00:42:49.740 --> 00:42:53.150
and before G. Because
H is smaller than G.

00:42:53.150 --> 00:43:03.710
You guys told me E before F.
And you guys told me I before J.

00:43:03.710 --> 00:43:07.120
And you guys would be
correct in all regards.

00:43:07.120 --> 00:43:12.490
We have 6, 7, 2, 3, 1, 20.

00:43:12.490 --> 00:43:15.450
All the minimizers choose
from smallest to highest.

00:43:15.450 --> 00:43:19.840
The maximizer chooses from
highest to lowest of the ones

00:43:19.840 --> 00:43:21.690
that the minimizers will take.

00:43:21.690 --> 00:43:24.320
And if we did that, you
can see we would probably

00:43:24.320 --> 00:43:26.160
save some time.

00:43:26.160 --> 00:43:27.640
Let's see how much time.

00:43:27.640 --> 00:43:30.770
Let's say we looked at H first.

00:43:30.770 --> 00:43:34.010
Well, if we looked
at H first, we

00:43:34.010 --> 00:43:39.060
would still have actually had
to look at Q and N. However,

00:43:39.060 --> 00:43:43.340
we would not have had to
look at K. Do people see why?

00:43:43.340 --> 00:43:44.970
If we already knew
this branch was 6,

00:43:44.970 --> 00:43:48.160
as soon as we saw 2 for the
beta here-- 2 is less than 6--

00:43:48.160 --> 00:43:49.752
we could have pruned.

00:43:49.752 --> 00:43:51.710
We still would have had
to look at I over here.

00:43:51.710 --> 00:43:53.480
Because you have to
look at at least one

00:43:53.480 --> 00:43:55.760
thing in the new sub-branch.

00:43:55.760 --> 00:44:00.500
And it actually only would
have saved us one node-- oops.

00:44:00.500 --> 00:44:04.740
So it winds up that in
total, how many nodes would

00:44:04.740 --> 00:44:10.350
we have evaluated if we did that
little scheme of reordering?

00:44:10.350 --> 00:44:17.050
Well, we normally had to
do six-- E, K, Q, N, H, I.

00:44:17.050 --> 00:44:20.391
How many do we evaluate if we
do this progressive deepening

00:44:20.391 --> 00:44:20.890
scheme?

00:44:20.890 --> 00:44:22.845
How many times do we run
the static evaluator,

00:44:22.845 --> 00:44:24.970
which of course you know
the static evaluator takes

00:44:24.970 --> 00:44:26.620
a long time?

00:44:26.620 --> 00:44:29.400
Anyone have a guess?

00:44:29.400 --> 00:44:36.170
I told you the only one we don't
evaluate is K. Raise your hand.

00:44:36.170 --> 00:44:40.460
I won't make anyone
give this one.

00:44:40.460 --> 00:44:43.410
So I said the only
one we save on is K.

00:44:43.410 --> 00:44:49.180
So we still do E, Q,
N, H, and I over here.

00:44:49.180 --> 00:44:51.180
There's two possible
answers that I will accept.

00:44:51.180 --> 00:44:53.171
So you have a higher
chance of guessing it.

00:44:53.171 --> 00:44:53.670
Anyway?

00:44:57.200 --> 00:44:59.405
Does everyone agree
that we did six before?

00:44:59.405 --> 00:45:01.210
If we didn't do any
progressive deepening,

00:45:01.210 --> 00:45:08.932
we just did E, K, Q, N, H, I.
And now we're not doing K. OK,

00:45:08.932 --> 00:45:09.890
people are saying five.

00:45:09.890 --> 00:45:11.074
All right, good.

00:45:11.074 --> 00:45:12.240
That's not the right answer.

00:45:12.240 --> 00:45:15.680
But it at least shows that you
can do taking away the one.

00:45:15.680 --> 00:45:17.489
We did at least five over here.

00:45:17.489 --> 00:45:19.030
There's two possible
answers, though.

00:45:19.030 --> 00:45:20.412
Because look over there.

00:45:20.412 --> 00:45:22.120
In order to do the
progressive deepening,

00:45:22.120 --> 00:45:27.850
we had to do those static
evaluations, right?

00:45:27.850 --> 00:45:34.190
So we either did all
those static evaluations

00:45:34.190 --> 00:45:39.470
and these five-- E, K, Q, N,
H, I-- static evaluations.

00:45:39.470 --> 00:45:42.590
Because we didn't do the K.

00:45:42.590 --> 00:45:46.010
Or we might have
saved ourselves.

00:45:46.010 --> 00:45:47.970
Because maybe we were
smart and decided

00:45:47.970 --> 00:45:51.899
to cache the static values when
we were going down the tree.

00:45:51.899 --> 00:45:54.440
It's an implementation detail
that on this test when we asked

00:45:54.440 --> 00:45:56.210
that question we didn't say.

00:45:56.210 --> 00:45:58.400
What I mean by cache is
when we did it here and saw

00:45:58.400 --> 00:46:01.540
that E was a 2, and
then here-- oh, we

00:46:01.540 --> 00:46:03.990
have to do the static value
at E. If we were smart,

00:46:03.990 --> 00:46:06.520
we might have made a little
hash table or something

00:46:06.520 --> 00:46:09.985
and put down 2 so we didn't have
to do a static evaluation at E.

00:46:09.985 --> 00:46:12.602
And if that happened,
well, we save E, H, and I,

00:46:12.602 --> 00:46:15.270
and we do three fewer.

00:46:15.270 --> 00:46:16.660
Does everyone see that?

00:46:16.660 --> 00:46:18.177
However, that's
still more than six.

00:46:18.177 --> 00:46:19.260
So it didn't save us time.

00:46:19.260 --> 00:46:21.051
So you might say, oh,
progressive deepening

00:46:21.051 --> 00:46:22.250
is a waste of time.

00:46:22.250 --> 00:46:23.670
But it's not.

00:46:23.670 --> 00:46:28.050
Because this is a very, very
small, not very branchy tree

00:46:28.050 --> 00:46:30.750
that was made so that
you guys could easily

00:46:30.750 --> 00:46:34.060
do alpha-beta and take the
quiz, and it wouldn't be bad.

00:46:34.060 --> 00:46:40.120
If this was actually branching
even double at each level,

00:46:40.120 --> 00:46:44.310
it would have, what, 16 nodes
down here at the bottom.

00:46:44.310 --> 00:46:47.390
Then you would want to be doing
that progressive deepening.

00:46:47.390 --> 00:46:51.360
So now I ask you a
conceptual riddle question.

00:46:51.360 --> 00:46:53.180
It's not really that
much of a riddle.

00:46:53.180 --> 00:46:54.846
But we'll see if
anyone wants to answer.

00:46:54.846 --> 00:46:57.670
Again, I won't call
on you for this.

00:46:57.670 --> 00:46:59.730
According to this
test, a student

00:46:59.730 --> 00:47:01.730
named Steve says,
OK, I know I have

00:47:01.730 --> 00:47:05.320
to pay to do the
progressive deepening here.

00:47:05.320 --> 00:47:06.490
But let's ignore that.

00:47:06.490 --> 00:47:09.320
Because it's small in
a large tree, right?

00:47:09.320 --> 00:47:11.320
It's not going to
take that much.

00:47:11.320 --> 00:47:13.720
Let's ignore the costs of
the progressive deepening

00:47:13.720 --> 00:47:16.450
and only look at
how much we do here.

00:47:16.450 --> 00:47:18.920
He says, when it comes to
performing the alpha-beta

00:47:18.920 --> 00:47:21.220
on the final level,
I'm guaranteed

00:47:21.220 --> 00:47:23.600
to always prune at
least as well or better

00:47:23.600 --> 00:47:25.970
if I rearrange the nodes
based on the best result

00:47:25.970 --> 00:47:27.830
from progressive deepening.

00:47:27.830 --> 00:47:28.759
Do you agree?

00:47:31.876 --> 00:47:32.751
AUDIENCE: [INAUDIBLE]

00:47:32.751 --> 00:47:34.250
PROFESSOR: Can I repeat it?

00:47:34.250 --> 00:47:36.850
OK, the question is,
ignoring the cost

00:47:36.850 --> 00:47:39.170
that we pay progressively
deepening here-- just

00:47:39.170 --> 00:47:42.295
forget about it-- at the final
step, at the final iteration,

00:47:42.295 --> 00:47:45.590
the question is, am I
guaranteed to do at least as

00:47:45.590 --> 00:47:47.530
well or better in my
alpha-beta pruning

00:47:47.530 --> 00:47:51.137
when I reorder based
on the best order

00:47:51.137 --> 00:47:52.220
for progressive deepening?

00:47:52.220 --> 00:47:53.935
Here certainly we did.

00:47:53.935 --> 00:47:57.020
But the question is,
is Steve guaranteed?

00:47:57.020 --> 00:47:58.526
Answer?

00:47:58.526 --> 00:47:59.675
AUDIENCE: [INAUDIBLE]

00:47:59.675 --> 00:48:00.841
PROFESSOR: What did you say?

00:48:00.841 --> 00:48:02.162
AUDIENCE: [INAUDIBLE]

00:48:02.162 --> 00:48:03.870
PROFESSOR: That's the
answer and the why,

00:48:03.870 --> 00:48:05.150
which we asked to explain.

00:48:05.150 --> 00:48:08.160
The answer we got is, doesn't
that depend on the heuristic?

00:48:08.160 --> 00:48:09.025
Perfectly correct.

00:48:09.025 --> 00:48:11.130
The answer is, no,
we're not guaranteed,

00:48:11.130 --> 00:48:12.780
and it depends on the heuristic.

00:48:12.780 --> 00:48:14.920
So if we were
guaranteed, that would

00:48:14.920 --> 00:48:17.310
be our heuristic was
godlike, like this heuristic.

00:48:17.310 --> 00:48:18.960
If your heuristic
already tells you

00:48:18.960 --> 00:48:22.180
the correct answer no matter
what, don't do game search.

00:48:22.180 --> 00:48:25.340
Just go to the
empty chess board,

00:48:25.340 --> 00:48:28.170
put all the pieces
in the front rows,

00:48:28.170 --> 00:48:29.990
and run static
evaluator on that.

00:48:29.990 --> 00:48:33.110
And it'll say, oh, it looks
like with this game not

00:48:33.110 --> 00:48:36.466
started that white is stupid,
so black will win in 15 turns.

00:48:36.466 --> 00:48:37.340
And then you're done.

00:48:37.340 --> 00:48:38.690
And you don't do a search.

00:48:38.690 --> 00:48:41.290
We know that our heuristic
is flawed in some way.

00:48:41.290 --> 00:48:42.790
It could be very flawed.

00:48:42.790 --> 00:48:44.850
If it's flawed so
badly that it tells us

00:48:44.850 --> 00:48:47.320
a very bad result of what's
actually going to happen,

00:48:47.320 --> 00:48:49.646
even though we think the
minimizer is going to go to H,

00:48:49.646 --> 00:48:52.070
maybe it's wrong by a
lot and it goes to G.

00:48:52.070 --> 00:48:54.590
It could take us up
an even worse path

00:48:54.590 --> 00:48:56.180
and make us take longer.

00:48:56.180 --> 00:48:56.972
Question?

00:48:56.972 --> 00:48:58.506
AUDIENCE: If it's
the heuristic, how

00:48:58.506 --> 00:48:59.804
could you cache the
values so you didn't

00:48:59.804 --> 00:49:01.096
have to recalculate them later?

00:49:01.096 --> 00:49:02.720
PROFESSOR: The question
is, how can you

00:49:02.720 --> 00:49:04.780
cache the values if it's
a heuristic so you don't

00:49:04.780 --> 00:49:06.390
have to recalculate them later?

00:49:06.390 --> 00:49:09.770
The answer is, it wouldn't
help if there weren't

00:49:09.770 --> 00:49:11.780
these weird multi-level
things where

00:49:11.780 --> 00:49:14.860
we stop at E for some reason,
even though it goes down

00:49:14.860 --> 00:49:16.270
to five levels.

00:49:16.270 --> 00:49:19.430
The way you could cache
it is it is a heuristic.

00:49:19.430 --> 00:49:20.635
But it's consistent.

00:49:20.635 --> 00:49:22.960
And I don't mean
consistent from search.

00:49:22.960 --> 00:49:25.890
I mean it's a consistent
heuristic in-- the game state

00:49:25.890 --> 00:49:29.190
E is, let's say that's the
state where I moved out

00:49:29.190 --> 00:49:31.530
my knight as the maximizer,
and the minimizer said,

00:49:31.530 --> 00:49:33.270
you're doing the
knight opening, really,

00:49:33.270 --> 00:49:35.820
and then did a counterattack.

00:49:35.820 --> 00:49:37.740
No matter how we
get to E, or where

00:49:37.740 --> 00:49:40.980
we go to get to E, that's
always going to be state E.

00:49:40.980 --> 00:49:43.430
It's always going to have
the same heuristic value.

00:49:43.430 --> 00:49:46.730
It's not like some guy who goes
around and just randomly pulls

00:49:46.730 --> 00:49:49.007
a number out of a hat.

00:49:49.007 --> 00:49:50.840
We're going to have
some value that gives us

00:49:50.840 --> 00:49:52.510
points based on
state E. And it's

00:49:52.510 --> 00:49:54.670
going to be the same
any time we go to state

00:49:54.670 --> 00:49:57.020
E. Does that make sense?

00:49:57.020 --> 00:49:57.980
It is a heuristic.

00:49:57.980 --> 00:50:01.250
But it's always going to give
the same value at E no matter

00:50:01.250 --> 00:50:04.500
how you got to E.

00:50:04.500 --> 00:50:05.705
But it could be really bad.

00:50:05.705 --> 00:50:07.330
In fact, you might
consider a heuristic

00:50:07.330 --> 00:50:09.830
that's the opposite of correct
and always tells us the worst

00:50:09.830 --> 00:50:11.112
move and claims it's the best.

00:50:11.112 --> 00:50:13.070
That's the heuristic that
the minimizer program

00:50:13.070 --> 00:50:14.860
did to our computer, perhaps.

00:50:14.860 --> 00:50:17.450
In that case, when we do
progressive deepening and we

00:50:17.450 --> 00:50:22.100
reorder, we'll probably get
the worst pruning possible.

00:50:22.100 --> 00:50:22.880
We might not.

00:50:22.880 --> 00:50:23.830
But we may.

00:50:23.830 --> 00:50:26.560
So in that case,
you're not guaranteed.

00:50:26.560 --> 00:50:28.450
I hope that's given a few clues.

00:50:28.450 --> 00:50:30.090
In tutorial, you
guys are going to see

00:50:30.090 --> 00:50:32.500
some more interesting
problems that

00:50:32.500 --> 00:50:33.870
go into a few other details.

00:50:33.870 --> 00:50:36.160
I at least plan on doing
[INAUDIBLE] interesting game

00:50:36.160 --> 00:50:41.649
problem from last year, which
asked a bunch of varied things

00:50:41.649 --> 00:50:43.440
that are a little bit
different from these.

00:50:43.440 --> 00:50:47.360
So it should be a lot of fun,
hopefully, or at least useful,

00:50:47.360 --> 00:50:49.910
to do the next quiz.

00:50:49.910 --> 00:50:51.550
So have a great weekend.

00:50:51.550 --> 00:50:54.711
Don't stress out too
much about the quiz.