Hey everyone so done with the USA's move.
And now we are going to perform the same faulty computer move that will define a function that is like
compute the move
and in computer move what we are going to do here is like computer books by the instruction that we
provide.
So we have to provide instruction in such a way that this will work like its own thinking.
So for that first of all we need a list of possible most that the computer can have so that it will
take a move from that.
So that list will be something a little typical that is x for x and y come up later in enumerate.
That is a function that provides all the values of a level that is lacking of a figure.
We have nine books data to provide all the nine inputs in that particular value of a life.
We have a board.
And then this enumerate This is a.
E here and you me.
And this is it.
So here this has a color of this light green in this one that so I spotted that something is wrong in
that.
After that if letter equal to N and destroying like these a position there and this will not equal to
zero.
So here we have not equal to zero then we will define the mood for computer and initial value will be
zero because it's just a position.
So an integer value not an empty string.
After that here there is a complex loop.
I hope you understand.
Here I have a for loop in which I take over the table left for let in all the possible values that are
O and x.
That's the only values we have.
So for these values and then again I'll loop for Hal in possible moves because we also need to work
in perceive moves and this one oh I have no values here.
So for these like first only in this list and then the possible moves available like is there any empty
space at that point or not like that one then we have a variable that is bold copy it will equal to
bold and they released their after that they will update the board be at particular I and so we have
taken l here let me also convert this one I think those EISA basic variable.
So this one I and a bit this one with the left that is either this one or this one and then if it is
Veena objective the for that one bold copy and then let more will begin I and return more.
So here's something like here first I'm checking by taking over a label that is led and that will perform
a loop in a list in which we have two elements that is 0 and X and then the same thing for the eye in
possible moves that this deadline is possible in the Mosul note and the possible moves you know that
these possible moves are just the numerical values and I will have then a temporary variable that is
a bold copy contains the list and then I will update that board copy element at that particular location
that is in the possible moves equal to let the thing here happening is the temporary variable that I
have taken whose value is the empty value or you can see that the ever value at the board and this is
in the like I have given this board value to this board copy element that is just temporary element
and that value that is empty there at that particular value I was just selected from D I have given
that value the O or the X and indicates of computer it may always be 0 and then I have checked for winner
if that let the particular value that is accurate there is that a winner or not and that particular
situation then if that is a winner then the move become I and we have returned the move this is something
happening in this function and I hope you understand this one known there are steps that the computer
is going to perform by virtue Vince every time and that says something like I go like corner first then
made value not mud it's made and then the edges.
So I was first check all the coordinate values and if that ever level then I will go for them then I
will check for the middle values and then the edge values so 40 corner values I will take a
list here that is an empty list in the beginning and what will I do I will check for all the values
in possible values that are they coordinate values and this is something like for I impossible values
all of it into that position most dear if I in one holy corner says like if I have the data here you
know that corners out on 1 3 then we have the 7 and then we have 9 these are the four corners of that
particular and what's happening here is first I's checking into all the possible most bad which all
the possible moves are equal to these like if in possible move we have 1 3 then the output of all of
this will be 1 and 3 this list.
So if any of this is ever Labor I will update this list that is coordinates open and append this one
with all the ever levels available values like if one is available it will be appended bit but if trees
every level then it's also appended with three.
So here I get the list of the available values and if there is some available values like what if there
is no value available so we also need to check the available values and I am telling you this one is
a little faster way because that is about today.
So here I have Len tough go no open that is like when I check for all the values available if there
are no values then the Lent of corners or put will be zero it will not be.
And even so if that is greater than zero then what will happen in that case.
So in that case my move.
Net is my location at which I need to store the value will be randomly from all this value available
like if I get an output of the list 3 and 9 then the computer will select a random value from these
two and make move do it.
So I will select random value and instead of writing the random code here I will just write a random
function that we define in the next video decoding or SOPA that select our value from this list randomly.
After that written that value as a move.
So that's what you know we need to do for the coordinate moves.
Now second thing is when the center value that is the five is every labor that is impossible moves.
In that case this is the second thing the computer do it by itself first it will check for decoder values
then it will check for the middle value then in that gives the move will become five and just return
more not that it is after that we are also done with the moves.
Then we will do the same thing for the edges.
So we will have a list that is edges open and an empty list.
Then for Pi in possible moves not
I n possible moves.
What I will do I will search the AI in the edges and the edges we have up to 4 6 and 8.
You can also on these on your detector.
After that we will append that edge is open with the AI values.
I hope you get it.
Now we have a list of edges open in which we have any of these values then to enter that value.
We will do the same if land of the edges value is open here is greater than zero.
So in that case of a move will again be something like select random out of the edges open and then
just return the more.
So here we are with this.
So this is the a code that will actually work like computer own thinking capability and it will provide
us the output.
It doesn't let us win.
So here we are done with the computer move also and barely makes it.
So we have done all these functions now.
We will continue in the next video.
Thanks for watching.