1 00:00:05,610 --> 00:00:06,820 Hey everyone. 2 00:00:06,870 --> 00:00:09,370 So now we have also decided who is the winner. 3 00:00:09,390 --> 00:00:17,280 Now we are going for deep play a move that is something going to be a little harder to understand but 4 00:00:17,340 --> 00:00:24,010 I believe you will understand this one also because you will love you know other students. 5 00:00:24,150 --> 00:00:29,950 So in player move before writing the call we need to understand something. 6 00:00:30,180 --> 00:00:33,110 That is when we are getting that here. 7 00:00:33,120 --> 00:00:38,430 If you notice let me have this one again here. 8 00:00:38,430 --> 00:00:41,780 This one is asking please select a position to place an X. 9 00:00:41,970 --> 00:00:49,410 So here first thing is I need to add any position that is from 1 2 9 that is going to buy my input but 10 00:00:49,650 --> 00:00:56,400 if you remember that whenever we take any input like we have done before in numbers as it dropped then 11 00:00:56,430 --> 00:00:59,370 that number will be taken in form of string. 12 00:01:01,020 --> 00:01:06,530 So one thing before writing any code you need to remember that this string is taken as an input in Python 13 00:01:06,530 --> 00:01:07,350 3. 14 00:01:07,440 --> 00:01:10,440 So we need to convert this string into Indonesia. 15 00:01:10,590 --> 00:01:20,790 Second thing is what if I am not me and you use it something other than 1 or 1 2 9 like he add something 16 00:01:20,790 --> 00:01:27,660 like any alphabet or any number greater than nine then we need to make our program know that that thing 17 00:01:27,660 --> 00:01:29,220 is invalid. 18 00:01:29,280 --> 00:01:35,340 So that program will not show any error and it will show something as like Please enter a valid correct. 19 00:01:35,370 --> 00:01:36,780 So we have to focus on 20 00:01:41,100 --> 00:01:43,200 valid characters. 21 00:01:43,290 --> 00:01:45,160 That is we have also done in hangman. 22 00:01:45,200 --> 00:01:47,540 You remember that. 23 00:01:47,640 --> 00:01:55,560 So we have to focus on these valued characters that either they are the third thing that is what if 24 00:01:55,560 --> 00:02:03,990 I write something like you have to and I again write on that particular position then somebody before 25 00:02:03,990 --> 00:02:05,340 writing me in the computer. 26 00:02:05,350 --> 00:02:07,840 Vince let me again. 27 00:02:07,840 --> 00:02:13,700 And that here came by like I have entered first. 28 00:02:13,720 --> 00:02:19,780 Then I again to write on first then please select and in that position this one is occupied so that 29 00:02:19,780 --> 00:02:21,190 one is also a case. 30 00:02:21,610 --> 00:02:23,500 So we have to also focus on 31 00:02:27,390 --> 00:02:29,600 focus on space. 32 00:02:29,670 --> 00:02:30,880 Is it available or not. 33 00:02:31,350 --> 00:02:38,990 So these are the three main things that we need to focus why they use it inputs any value. 34 00:02:39,120 --> 00:02:50,740 And again we define a function that is player move that makes a sense I believe for player move we do 35 00:02:50,740 --> 00:02:57,720 not divide any barometer that's because that is just we need an input that we take inside the function 36 00:03:00,490 --> 00:03:06,040 because passing the parameter in that case that is a little difficult to convert that from one to another. 37 00:03:06,520 --> 00:03:15,520 So we will take a variable that is one that will turn the code and that will be true in case in the 38 00:03:15,520 --> 00:03:18,340 beginning then Day function get its first input. 39 00:03:19,270 --> 00:03:25,000 So we will apply here Vilde run by layer that run is true. 40 00:03:25,930 --> 00:03:30,760 So this is I have done you will understand when I write the complete code here. 41 00:03:31,390 --> 00:03:33,840 So first of all I will take the input. 42 00:03:34,180 --> 00:03:38,070 So here this values because I need to get input again and again. 43 00:03:38,140 --> 00:03:45,130 So whenever that run will be true like whenever my Duncan then add that position this will become true 44 00:03:45,610 --> 00:03:50,470 and I need to have input the value so input. 45 00:03:50,860 --> 00:03:52,090 Something like please 46 00:03:54,340 --> 00:03:55,270 select 47 00:03:57,620 --> 00:04:03,280 position position to enter the 48 00:04:06,250 --> 00:04:06,850 X 49 00:04:09,340 --> 00:04:20,780 between 1 to 9 and then like that you can add any string like into this one we have a different one 50 00:04:20,780 --> 00:04:31,330 but here I have written this one because that one is I have right before now do things like space and 51 00:04:31,360 --> 00:04:37,150 all the things that we have to focus on now we will apply them but this time we are going to use something 52 00:04:37,210 --> 00:04:47,080 as then if an LS That is a new thing you gotta to learn that is dry there are two statements you can 53 00:04:47,080 --> 00:04:56,710 see this one and also double because it's a pre-defined one and except this one is also like if ls but 54 00:04:57,040 --> 00:05:03,090 it has a proper use in some situations like the one that we are dealing with and this one is a homework 55 00:05:03,100 --> 00:05:06,030 for you to understand these two network there. 56 00:05:06,460 --> 00:05:15,400 Now first thing the input that I have taken so it will try to make the input first into the integer 57 00:05:15,400 --> 00:05:22,780 value so we have in most because that one is a string as I have told you so trusting done that we have 58 00:05:22,780 --> 00:05:23,640 done. 59 00:05:23,920 --> 00:05:31,570 Second thing about the well it characters so the acting the also is due here. 60 00:05:31,630 --> 00:05:37,600 But before that if move is greater than zero. 61 00:05:37,620 --> 00:05:42,880 Like what if the user doesn't enter anything and 62 00:05:46,100 --> 00:05:46,970 now this thing. 63 00:05:47,570 --> 00:05:54,770 Well in addition to that it's range that will be less than 64 00:05:58,500 --> 00:05:59,490 10. 65 00:05:59,550 --> 00:06:04,500 So here you can also take this statement like between from zero to 10. 66 00:06:04,500 --> 00:06:05,640 We have done this thing. 67 00:06:05,670 --> 00:06:08,980 And second is a move and it's greater than zero. 68 00:06:09,150 --> 00:06:13,180 Like I can add something like just empty and hit enter. 69 00:06:13,330 --> 00:06:15,200 So I will get please type a number. 70 00:06:15,810 --> 00:06:20,720 So the thing here the number must be greater than zero and less than nine. 71 00:06:20,720 --> 00:06:25,600 And there must be something that like something cannot be void. 72 00:06:25,650 --> 00:06:30,420 Now here if this thing is greater than zero and move less than 10. 73 00:06:30,960 --> 00:06:41,490 So in that case we will make our loop stop because after our turn it will be computers done so run really 74 00:06:41,520 --> 00:06:43,050 well to falls. 75 00:06:43,260 --> 00:06:46,630 So that computer will get to know that. 76 00:06:46,640 --> 00:06:55,950 Now his turn came and then we just insert the letter that is we use the insert letter function that 77 00:06:55,950 --> 00:07:02,080 if the position is there then it will insert the value in that particular position. 78 00:07:02,140 --> 00:07:07,240 So that's what we have we do not have to return any value because we just need to add that particular 79 00:07:07,240 --> 00:07:09,080 value to that position. 80 00:07:09,190 --> 00:07:13,180 So we will use that function here because now we require the insertion. 81 00:07:13,180 --> 00:07:22,900 So insert that value and that value will be capital of X and then the next parameter that is our position 82 00:07:23,170 --> 00:07:31,090 is move because if you notice the user enter the number and that number is not the value of a value 83 00:07:31,090 --> 00:07:37,180 is X. We have only two values that is an X move is deportation. 84 00:07:37,240 --> 00:07:40,410 So that's why we have converted this one into into value. 85 00:07:40,660 --> 00:07:47,680 And then we have passed this bill barometer restive position because in insert letter we have two parameters. 86 00:07:48,010 --> 00:07:52,140 I think you get this one that what I have done before. 87 00:07:53,180 --> 00:07:53,970 So are we done here. 88 00:07:54,370 --> 00:08:06,630 And after that as they will return something like print and this statement sorry 89 00:08:09,520 --> 00:08:15,910 this space is occupied. 90 00:08:16,150 --> 00:08:26,140 And for that we do not have another thing to return him just to do things like sort of the spaces occupied 91 00:08:26,380 --> 00:08:27,580 and for that also. 92 00:08:29,470 --> 00:08:38,020 Now if we want to add this we require a statement also here that is if space is free. 93 00:08:38,020 --> 00:08:46,540 That is where this function for the particular position that is move then it will do this thing. 94 00:08:47,080 --> 00:08:51,430 So command X this one and come on this one 95 00:08:54,720 --> 00:08:57,840 forget to mention dysfunction here. 96 00:08:57,900 --> 00:08:59,670 So this condition now. 97 00:09:00,030 --> 00:09:08,190 This is done that if this space is free we have used these space free from space is free. 98 00:09:08,250 --> 00:09:15,240 This one then it will insert the value on that particular position and if not then it will require the 99 00:09:15,240 --> 00:09:16,180 space is free. 100 00:09:16,230 --> 00:09:22,610 Now if the we are done with this free space now the valid collector. 101 00:09:22,680 --> 00:09:26,200 Now if the character is valid then it will do this thing. 102 00:09:26,430 --> 00:09:27,150 A device 103 00:09:30,000 --> 00:09:31,800 is to ensure something like 104 00:09:35,720 --> 00:09:36,290 print 105 00:09:38,960 --> 00:09:39,650 please 106 00:09:42,960 --> 00:09:49,830 type on number between 1 and 9 here. 107 00:09:49,830 --> 00:09:52,260 Space until now. 108 00:09:52,300 --> 00:09:52,720 Here. 109 00:09:52,730 --> 00:09:53,040 This. 110 00:09:53,040 --> 00:09:59,940 If you get back as now we have focus on the value the collector also string us. 111 00:09:59,980 --> 00:10:03,060 Now we are done with this play and move completely. 112 00:10:03,310 --> 00:10:08,560 Just this expect condition like when this drag out failed. 113 00:10:08,860 --> 00:10:11,290 What to do in that case. 114 00:10:11,540 --> 00:10:12,130 Print 115 00:10:14,810 --> 00:10:21,740 This one happens when like something if I enter these things. 116 00:10:21,740 --> 00:10:24,300 So here in that case I will write. 117 00:10:24,670 --> 00:10:25,280 Please 118 00:10:28,300 --> 00:10:29,220 type. 119 00:10:29,290 --> 00:10:29,950 No. 120 00:10:31,600 --> 00:10:37,240 So if the user doesn't enter the number then in that case this thing happens because on that point this 121 00:10:37,390 --> 00:10:41,480 code shows error that they cannot convert the string type into. 122 00:10:42,100 --> 00:10:48,220 So these conditions get full display in that case get in that case get filled. 123 00:10:48,220 --> 00:10:51,100 So in that case this acceptable. 124 00:10:51,100 --> 00:10:53,860 [REMOVED] that please type a number. 125 00:10:53,980 --> 00:11:01,660 So if you go from the very inside of this code and this code also requires you to focus because you 126 00:11:01,660 --> 00:11:07,370 get confused that at which position you have to enter what syntax like. 127 00:11:07,390 --> 00:11:10,750 I also forget where Dave condition in the particular case here. 128 00:11:11,500 --> 00:11:20,740 So first thing it will insert that particular reactor at the position move and done they run through 129 00:11:20,750 --> 00:11:27,100 files so that it will be computer stuff and this thing only happens when there is a space free. 130 00:11:27,340 --> 00:11:32,420 If the space is not free we will show an alert for spaces occupied. 131 00:11:32,890 --> 00:11:39,730 Now this whole can only work when the number is in the valid range. 132 00:11:39,730 --> 00:11:41,310 Please Dave I'm sorry. 133 00:11:41,410 --> 00:11:46,690 When the number is valid range and if that is not we will surely alert like Please type a number between 134 00:11:46,690 --> 00:11:49,590 1 and drain because that's over French. 135 00:11:50,120 --> 00:11:58,000 And in case this whole try get failed when the user input like something integer type sorting string 136 00:11:58,010 --> 00:12:04,450 develops in that case this doesn't convert that one into number and we get added. 137 00:12:04,510 --> 00:12:11,630 So when this drag it filled the acceptable will work that will show print as please type a number. 138 00:12:12,250 --> 00:12:23,650 The thing we have used try and accept instead of defendants because in effect as only you know the condition 139 00:12:23,650 --> 00:12:30,940 is check like if I write a written here the if then if these conditions begin false that is it is not 140 00:12:30,940 --> 00:12:34,350 able to convert that one so it will show error. 141 00:12:35,320 --> 00:12:40,930 So try and expect something that shows the and that works on the values when the inner program will 142 00:12:40,930 --> 00:12:45,770 work or not drag it failed when the inner program is show. 143 00:12:46,210 --> 00:12:48,560 Otherwise it will work. 144 00:12:48,790 --> 00:12:51,140 So that's about the player mood. 145 00:12:51,430 --> 00:12:55,200 I hope you understand because this one is a little typical to understand. 146 00:12:55,360 --> 00:13:00,680 You have to go from the inside and then try to understand coming outwards. 147 00:13:00,750 --> 00:13:06,770 That's why it's a little hard to write this one from first here to going inside. 148 00:13:07,940 --> 00:13:09,690 So thanks for watching. 149 00:13:09,940 --> 00:13:20,380 And we're also done with the player move now and under more typical task writing the computer that we 150 00:13:20,380 --> 00:13:22,270 are going to do in the next video. 151 00:13:22,270 --> 00:13:25,270 So thanks for watching and we will continue in the next video.