Now you're writing the mm move function, mm move takes two arguments.
It takes a board which is the current board and
it takes the player who is supposed to move next, okay.
And what it returns is both a score, and a move, right?
A move that's going to get that score, Okay?
And that score is either the maximum, or minimum
depending on who you're up, who you're playing, right?
If you're playing player X you're going to return the maximum score
you can get, and the move that get's that maximum score.
If you're playing play, player O, you return the minimum score you
can get, and the move that you know, get's that score OK.
Now there are some boards however.
The, you know there is no move.
Well, how can that be?
If the game is over, you're just going to score it, you're
going to give it a minus one a zero, or a one.
And in that cases you have no move to return, so let's just move the
convention here, that in that case you're going to
return that move minus one minus one, okay?
All right?
Now, we have some additional stuff in the template here, okay?
We want to be able to use exactly the
same infrastructure that we used for the Monte Carlo tic
tac toe player, but if you remember, the Monte
Carlo tic tac toe player had a different interface, okay?
First of all, it took a board, a player, and a number of trials,.
And second of all it just returned the mood it didn't return the score okay.
So we have to sort of have this wrapper function okay.
Instead of trying to make our our our Minimax
move behave exactly the same we're going to have this thing
called move wrapper, that looks like the Monte Carlo
function board player number of trials, and returns a move.
And what it does is it actually calls your Minimax player,
okay, inside, and returns the move that your Minimax player returned, okay?
This allows us to use exactly the same code we
used before to run the Monte Carlo player, all right?
So don't modify that Move wrapper.
You can uncomment and play.
And one thing I will caution you again, Don't uncomment that
and try to play with Player x as the first player.
All right?
Or as the machine player.
Right?
If you do that, okay, you're going to incur that very long delay, all right?
Waiting for that first move to happen.
And so when you hit run, it's just going to sit there for, you know,
30 seconds or whatever while you're Minimax
player's trying to decide where to play X.
And there's just a couple more things that I would like to point
out about your minimize players here, okay and the first is as follows.
I know the score is always going to be one zero or minus one, no matter what.
So that means if I'm in a maximizing layer, as soon as I find.
A move that would return, that returns a square of
one, I know I can't do any better, all right?
And so there's no point in checking the other moves to see if,
if you know, are there other ways that I can win the game, right?
You already found a way that you can win the game.
You can return that move and that score
immediately, and this will speed up your player significantly.
Similarly, if you're playing for O, and
you're minimizing and you ever going to score
a minus one back, you know immediately, hey, this is the best I can do.
I may as well return a score of minus
one and whatever move gets me that score, okay?
This is important.
If you don't do this, your player's going to be significantly slower, all right?
Another thing that I want to point out is not, you know, the
way in which you search the moves is now going to matter, as well.
If I'm not going to search all of them there might be,
you know, particular squares on the board that's it's better to search first.
And if you search those first you're more likely to find a win.
And, you know, this early termination condition
would kick in sooner making things faster.
So you might want to experiment with the
ways in which you search the moves, all right,
but don't do that until you actually have a
working player but do do the early termination, okay.
Right from the start.
That'll make things much faster.
It'll make it much easier for you to work on the project and debug things.