1 00:00:02,350 --> 00:00:06,640 Come back we need a system in place to tell you is there when they win the game. 2 00:00:06,640 --> 00:00:12,070 Essentially if they manage to find every pair of the numbers on every pair of the tiles the system should 3 00:00:12,070 --> 00:00:14,800 tell them that you want the game and to do that. 4 00:00:14,800 --> 00:00:20,310 I'm actually having a particular strategy in mind that I'm going to write that down for you Scott as 5 00:00:20,470 --> 00:00:22,730 as comments so you can see what's going on. 6 00:00:22,900 --> 00:00:24,790 So here's my strategy. 7 00:00:24,790 --> 00:00:29,740 I'm going to go ahead and remember how many times I have already found. 8 00:00:29,870 --> 00:00:31,690 So let's go ahead and find one. 9 00:00:31,690 --> 00:00:34,100 This is 2006 not the right ones. 10 00:00:34,150 --> 00:00:35,020 Five on one. 11 00:00:35,020 --> 00:00:36,470 Not the right ones. 12 00:00:36,680 --> 00:00:37,930 Four six and six. 13 00:00:37,930 --> 00:00:38,860 These are the right ones. 14 00:00:38,860 --> 00:00:44,140 So by the end of this comparison I'm well remember the number of the sound ones. 15 00:00:44,290 --> 00:00:49,790 So I'm going to say remember the number of foundlings. 16 00:00:49,840 --> 00:00:52,360 So right now it has to let me add one more. 17 00:00:52,360 --> 00:00:58,660 So this is a more descriptive seven and two and three and zero zero. 18 00:00:58,660 --> 00:01:00,980 So now that number becomes four. 19 00:01:01,000 --> 00:01:02,770 So I have found four of them. 20 00:01:02,980 --> 00:01:11,110 Then each time I find a pair and I do them I compare the total number against the entire number of the 21 00:01:11,110 --> 00:01:11,880 times. 22 00:01:12,100 --> 00:01:20,770 So compare found against total games total. 23 00:01:20,770 --> 00:01:27,160 So if I have four found ones and there are 16 total ones obviously I haven't won the game but if I have 24 00:01:27,160 --> 00:01:35,170 16 found ones under 16 total times it means I have won the game and let's go ahead and put this strategy 25 00:01:35,170 --> 00:01:38,120 into court to make sure that you know we get it. 26 00:01:38,440 --> 00:01:45,610 I want to come to my real control and say I have a new variable and they call this one found the levels 27 00:01:45,760 --> 00:01:54,580 array which is going to be an array of my label my label and it's going to be an optional one at the 28 00:01:54,580 --> 00:01:57,900 very beginning and I don't need any of these comments. 29 00:01:58,240 --> 00:02:04,080 So we have this one and then this one we have to at some point we have to reset it. 30 00:02:04,270 --> 00:02:04,960 What is it. 31 00:02:04,960 --> 00:02:08,180 Now I could make it an empty array and that's all. 32 00:02:08,200 --> 00:02:14,770 Well what we have to remember to reset it again in the Reset auction to I'm going to go to my reset 33 00:02:14,810 --> 00:02:22,270 auction which is here and say right at the beginning every time that you reset and the game time becomes 34 00:02:22,270 --> 00:02:23,030 zero. 35 00:02:23,080 --> 00:02:32,020 Also say founda times are also empty and then when do we add to this Fountain's we add to them every 36 00:02:32,020 --> 00:02:37,080 time that we do a compare and compare results in success. 37 00:02:37,090 --> 00:02:43,270 So here when we turn them into a smiley faces I'm going to go ahead and say fountain is the way that 38 00:02:43,350 --> 00:02:45,610 I spend first time. 39 00:02:45,850 --> 00:02:50,030 And then times range not append second time. 40 00:02:50,170 --> 00:02:54,860 So it means every time you found the right ones add them to this found array. 41 00:02:55,090 --> 00:03:01,450 And the last the step of the work was to compare the number of the elements in here against the number 42 00:03:01,510 --> 00:03:02,510 in the total. 43 00:03:02,650 --> 00:03:05,690 So it's go ahead and do that in a separate function. 44 00:03:05,730 --> 00:03:15,570 I'm actually going to go ahead and make a new file called this one view controller plus warn the state 45 00:03:18,070 --> 00:03:20,500 and I have the same things as before. 46 00:03:20,500 --> 00:03:21,260 You can't. 47 00:03:21,310 --> 00:03:25,860 This is an extension extension to view controller. 48 00:03:25,870 --> 00:03:31,340 It has only one function called Did we win. 49 00:03:31,670 --> 00:03:34,940 And it even does this. 50 00:03:34,990 --> 00:03:39,160 It says Let's find out how many of these values are there. 51 00:03:39,300 --> 00:03:43,580 If found tied is the rate that counts. 52 00:03:43,720 --> 00:03:47,690 If that is equivalent to what it would it be equivalent to. 53 00:03:47,710 --> 00:03:49,900 It can be written in several different ways. 54 00:03:49,900 --> 00:03:57,480 One of them is we have to get our game mode which is for instance a game mode multiplied by gameboard 55 00:03:57,610 --> 00:04:00,690 because that produces four by four 16. 56 00:04:00,680 --> 00:04:05,080 There also another place that we have that and that is the actual tiles. 57 00:04:05,140 --> 00:04:10,600 So I would say if these guys are equivalent to tiles array that counts. 58 00:04:10,720 --> 00:04:16,020 It means the number of the times we have found is the same number of the total tiles. 59 00:04:16,210 --> 00:04:22,570 And then when it gets rid of that say in that case we have gone and I'm going to show that in a very 60 00:04:22,570 --> 00:04:23,740 particular way. 61 00:04:23,830 --> 00:04:25,480 I have to do several things. 62 00:04:25,480 --> 00:04:34,690 I'm going to invalidate the timer say game timer that invalidate and then I'm going to write in here 63 00:04:35,470 --> 00:04:40,470 in this little game vorn that you've worn in a certain number of seconds. 64 00:04:40,510 --> 00:04:44,050 So I'm going to go ahead and say let's produce a little text. 65 00:04:44,060 --> 00:04:54,010 I'm going to say let sixty two be you want to in and then I'm going to have to add a little formatting 66 00:04:54,010 --> 00:04:55,570 in here for nothing. 67 00:04:55,630 --> 00:05:00,080 Is this the same thing we had done for the game time or before. 68 00:05:00,100 --> 00:05:04,150 So it's a bit of a long record but bear with me as I write it. 69 00:05:04,150 --> 00:05:07,550 It becomes game time. 70 00:05:07,810 --> 00:05:08,500 Not that. 71 00:05:08,500 --> 00:05:13,320 Game time divided by 60. 72 00:05:13,390 --> 00:05:18,870 That becomes our seconds then becomes a space and we put a column. 73 00:05:19,040 --> 00:05:22,240 Then we're going to go ahead and write another one. 74 00:05:22,270 --> 00:05:32,260 That other format is going to be game time modulus 60 and that's going to have a seconds sign and that's 75 00:05:32,260 --> 00:05:36,650 how we're going to see how much how much time it takes you to win. 76 00:05:36,700 --> 00:05:41,730 You could of course format it if you want to count for the leading zeros. 77 00:05:41,770 --> 00:05:44,020 I'm not going to really worry about that just now. 78 00:05:44,170 --> 00:05:50,590 So the T X is going to show up in that label down there which we haven't talked about in a very very 79 00:05:50,590 --> 00:05:51,680 long time. 80 00:05:51,700 --> 00:05:53,440 Let me go ahead and find it. 81 00:05:53,650 --> 00:05:58,150 It's actually called Game Move-On label and here's what I'm going to do with it. 82 00:05:58,420 --> 00:05:59,960 I'm going to go to my reset. 83 00:06:00,040 --> 00:06:04,010 I remember I said the reset function is something that we keep coming back to it. 84 00:06:04,210 --> 00:06:08,530 And there's still a lot of code left that I have to write and it's going to come up in the next few 85 00:06:08,530 --> 00:06:09,200 lessons. 86 00:06:09,400 --> 00:06:14,060 But for now I'm going to say Game 1 label that he's done. 87 00:06:14,200 --> 00:06:15,060 Is that true. 88 00:06:15,190 --> 00:06:20,590 So by default everything there he said it's hidden because we haven't won the game yet. 89 00:06:20,680 --> 00:06:25,830 By the end of all honesty I'm going to say game on his label. 90 00:06:26,250 --> 00:06:35,820 Is he then becomes false so it's not hidden anymore and came Warner-Levin dot text it becomes Stevy 91 00:06:35,860 --> 00:06:36,960 just produced. 92 00:06:37,090 --> 00:06:42,840 So it becomes the value that says you own in certain number of minutes and seconds. 93 00:06:42,850 --> 00:06:48,350 And finally I have to use that even Sumburgh and that is VTM they compare. 94 00:06:48,460 --> 00:06:49,790 So we tend to compare. 95 00:06:49,840 --> 00:06:56,170 I have to say every time you found the right ones and you added them to the found ones go ahead and 96 00:06:56,170 --> 00:06:57,640 say get to them. 97 00:06:57,840 --> 00:06:59,200 And that's about that. 98 00:06:59,200 --> 00:07:01,440 So let me go on the. 99 00:07:01,560 --> 00:07:03,610 And now let's see how we will do. 100 00:07:03,630 --> 00:07:26,610 I got zero on five and six countries 0 5 6 3 7 3 0 5 6 7 0 0 0 5 7 now I have and then 2 1 1 0 5 7 and 101 00:07:26,620 --> 00:07:39,530 I've got 5 and then 0 and then I've got one I think was there two is here and then this should be the 102 00:07:39,530 --> 00:07:40,580 last one. 103 00:07:40,710 --> 00:07:44,980 And then I tap on it this time I should pause and we should see that we move on. 104 00:07:45,060 --> 00:07:45,960 I press there. 105 00:07:46,100 --> 00:07:52,930 Yes you've on in zero minutes and 44 seconds and the timer is paused in there. 106 00:07:53,120 --> 00:07:54,220 That's it. 107 00:07:54,230 --> 00:07:55,780 We managed to make the game. 108 00:07:55,790 --> 00:07:58,830 That shows us how long it took us to win the game. 109 00:07:59,090 --> 00:08:01,510 And we have found every one in here. 110 00:08:01,760 --> 00:08:05,210 So let's move on to our next thing then.