1 00:00:05,630 --> 00:00:09,320 Hey everyone so done with the USA's move. 2 00:00:10,040 --> 00:00:21,830 And now we are going to perform the same faulty computer move that will define a function that is like 3 00:00:22,730 --> 00:00:25,970 compute the move 4 00:00:28,790 --> 00:00:36,710 and in computer move what we are going to do here is like computer books by the instruction that we 5 00:00:36,710 --> 00:00:37,130 provide. 6 00:00:37,400 --> 00:00:43,990 So we have to provide instruction in such a way that this will work like its own thinking. 7 00:00:44,420 --> 00:00:55,880 So for that first of all we need a list of possible most that the computer can have so that it will 8 00:00:55,880 --> 00:00:57,290 take a move from that. 9 00:00:57,500 --> 00:01:09,070 So that list will be something a little typical that is x for x and y come up later in enumerate. 10 00:01:09,290 --> 00:01:13,670 That is a function that provides all the values of a level that is lacking of a figure. 11 00:01:13,670 --> 00:01:19,440 We have nine books data to provide all the nine inputs in that particular value of a life. 12 00:01:19,460 --> 00:01:21,090 We have a board. 13 00:01:21,530 --> 00:01:25,370 And then this enumerate This is a. 14 00:01:25,520 --> 00:01:28,250 E here and you me. 15 00:01:28,480 --> 00:01:29,440 And this is it. 16 00:01:30,410 --> 00:01:36,470 So here this has a color of this light green in this one that so I spotted that something is wrong in 17 00:01:36,470 --> 00:01:37,680 that. 18 00:01:37,820 --> 00:01:52,460 After that if letter equal to N and destroying like these a position there and this will not equal to 19 00:01:52,460 --> 00:01:52,970 zero. 20 00:01:53,660 --> 00:02:01,850 So here we have not equal to zero then we will define the mood for computer and initial value will be 21 00:02:01,850 --> 00:02:04,160 zero because it's just a position. 22 00:02:04,160 --> 00:02:08,060 So an integer value not an empty string. 23 00:02:08,060 --> 00:02:13,060 After that here there is a complex loop. 24 00:02:13,130 --> 00:02:14,360 I hope you understand. 25 00:02:14,820 --> 00:02:24,830 Here I have a for loop in which I take over the table left for let in all the possible values that are 26 00:02:25,610 --> 00:02:28,980 O and x. 27 00:02:29,000 --> 00:02:31,880 That's the only values we have. 28 00:02:31,990 --> 00:02:40,430 So for these values and then again I'll loop for Hal in possible moves because we also need to work 29 00:02:40,430 --> 00:02:49,830 in perceive moves and this one oh I have no values here. 30 00:02:51,150 --> 00:02:58,020 So for these like first only in this list and then the possible moves available like is there any empty 31 00:02:58,020 --> 00:03:08,340 space at that point or not like that one then we have a variable that is bold copy it will equal to 32 00:03:09,570 --> 00:03:27,630 bold and they released their after that they will update the board be at particular I and so we have 33 00:03:27,630 --> 00:03:35,070 taken l here let me also convert this one I think those EISA basic variable. 34 00:03:35,070 --> 00:03:48,720 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 35 00:03:48,720 --> 00:04:12,070 Veena objective the for that one bold copy and then let more will begin I and return more. 36 00:04:14,310 --> 00:04:22,440 So here's something like here first I'm checking by taking over a label that is led and that will perform 37 00:04:22,440 --> 00:04:29,690 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 38 00:04:29,710 --> 00:04:36,330 possible moves that this deadline is possible in the Mosul note and the possible moves you know that 39 00:04:36,330 --> 00:04:42,570 these possible moves are just the numerical values and I will have then a temporary variable that is 40 00:04:42,570 --> 00:04:49,890 a bold copy contains the list and then I will update that board copy element at that particular location 41 00:04:50,220 --> 00:04:57,660 that is in the possible moves equal to let the thing here happening is the temporary variable that I 42 00:04:57,660 --> 00:05:07,660 have taken whose value is the empty value or you can see that the ever value at the board and this is 43 00:05:07,660 --> 00:05:16,290 in the like I have given this board value to this board copy element that is just temporary element 44 00:05:16,680 --> 00:05:26,530 and that value that is empty there at that particular value I was just selected from D I have given 45 00:05:26,530 --> 00:05:37,500 that value the O or the X and indicates of computer it may always be 0 and then I have checked for winner 46 00:05:38,110 --> 00:05:44,350 if that let the particular value that is accurate there is that a winner or not and that particular 47 00:05:44,350 --> 00:05:51,430 situation then if that is a winner then the move become I and we have returned the move this is something 48 00:05:51,430 --> 00:05:59,820 happening in this function and I hope you understand this one known there are steps that the computer 49 00:05:59,820 --> 00:06:09,160 is going to perform by virtue Vince every time and that says something like I go like corner first then 50 00:06:09,160 --> 00:06:14,840 made value not mud it's made and then the edges. 51 00:06:15,040 --> 00:06:21,910 So I was first check all the coordinate values and if that ever level then I will go for them then I 52 00:06:21,910 --> 00:06:30,770 will check for the middle values and then the edge values so 40 corner values I will take a 53 00:06:35,300 --> 00:06:44,370 list here that is an empty list in the beginning and what will I do I will check for all the values 54 00:06:44,570 --> 00:06:52,120 in possible values that are they coordinate values and this is something like for I impossible values 55 00:06:52,720 --> 00:07:06,330 all of it into that position most dear if I in one holy corner says like if I have the data here you 56 00:07:06,330 --> 00:07:15,060 know that corners out on 1 3 then we have the 7 and then we have 9 these are the four corners of that 57 00:07:15,240 --> 00:07:23,420 particular and what's happening here is first I's checking into all the possible most bad which all 58 00:07:23,430 --> 00:07:30,720 the possible moves are equal to these like if in possible move we have 1 3 then the output of all of 59 00:07:30,720 --> 00:07:34,350 this will be 1 and 3 this list. 60 00:07:34,620 --> 00:07:43,920 So if any of this is ever Labor I will update this list that is coordinates open and append this one 61 00:07:44,820 --> 00:07:52,590 with all the ever levels available values like if one is available it will be appended bit but if trees 62 00:07:52,590 --> 00:07:55,630 every level then it's also appended with three. 63 00:07:55,890 --> 00:08:04,350 So here I get the list of the available values and if there is some available values like what if there 64 00:08:04,350 --> 00:08:11,370 is no value available so we also need to check the available values and I am telling you this one is 65 00:08:11,450 --> 00:08:16,120 a little faster way because that is about today. 66 00:08:16,890 --> 00:08:25,620 So here I have Len tough go no open that is like when I check for all the values available if there 67 00:08:25,620 --> 00:08:30,270 are no values then the Lent of corners or put will be zero it will not be. 68 00:08:30,310 --> 00:08:37,340 And even so if that is greater than zero then what will happen in that case. 69 00:08:37,350 --> 00:08:39,310 So in that case my move. 70 00:08:39,320 --> 00:08:48,210 Net is my location at which I need to store the value will be randomly from all this value available 71 00:08:48,240 --> 00:08:55,890 like if I get an output of the list 3 and 9 then the computer will select a random value from these 72 00:08:55,890 --> 00:08:59,100 two and make move do it. 73 00:08:59,610 --> 00:09:07,680 So I will select random value and instead of writing the random code here I will just write a random 74 00:09:07,680 --> 00:09:17,260 function that we define in the next video decoding or SOPA that select our value from this list randomly. 75 00:09:17,790 --> 00:09:24,870 After that written that value as a move. 76 00:09:25,410 --> 00:09:32,030 So that's what you know we need to do for the coordinate moves. 77 00:09:32,250 --> 00:09:45,060 Now second thing is when the center value that is the five is every labor that is impossible moves. 78 00:09:45,060 --> 00:09:52,410 In that case this is the second thing the computer do it by itself first it will check for decoder values 79 00:09:52,720 --> 00:10:01,860 then it will check for the middle value then in that gives the move will become five and just return 80 00:10:02,100 --> 00:10:12,400 more not that it is after that we are also done with the moves. 81 00:10:12,400 --> 00:10:15,420 Then we will do the same thing for the edges. 82 00:10:15,520 --> 00:10:22,210 So we will have a list that is edges open and an empty list. 83 00:10:22,210 --> 00:10:26,740 Then for Pi in possible moves not 84 00:10:29,530 --> 00:10:31,320 I n possible moves. 85 00:10:31,790 --> 00:10:41,420 What I will do I will search the AI in the edges and the edges we have up to 4 6 and 8. 86 00:10:42,140 --> 00:10:46,730 You can also on these on your detector. 87 00:10:46,730 --> 00:10:54,270 After that we will append that edge is open with the AI values. 88 00:10:54,270 --> 00:10:55,140 I hope you get it. 89 00:10:55,830 --> 00:11:03,930 Now we have a list of edges open in which we have any of these values then to enter that value. 90 00:11:03,930 --> 00:11:16,880 We will do the same if land of the edges value is open here is greater than zero. 91 00:11:17,970 --> 00:11:31,890 So in that case of a move will again be something like select random out of the edges open and then 92 00:11:31,890 --> 00:11:34,500 just return the more. 93 00:11:35,400 --> 00:11:37,470 So here we are with this. 94 00:11:37,530 --> 00:11:44,910 So this is the a code that will actually work like computer own thinking capability and it will provide 95 00:11:44,910 --> 00:11:47,690 us the output. 96 00:11:47,760 --> 00:11:49,330 It doesn't let us win. 97 00:11:50,010 --> 00:11:55,530 So here we are done with the computer move also and barely makes it. 98 00:11:56,400 --> 00:11:59,310 So we have done all these functions now. 99 00:11:59,640 --> 00:12:01,770 We will continue in the next video. 100 00:12:01,770 --> 00:12:02,670 Thanks for watching.