WEBVTT

0
00:00.050 --> 00:00.560
Hey, guys.

1
00:00.560 --> 00:04.040
Welcome to Day 14 of 100 Days of Code.

2
00:04.070 --> 00:09.620
Today you're going to spend building a exciting game called Higher or Lower.

3
00:09.890 --> 00:15.770
And if you want to have a go at it just go over to higherlowergame.com and click on Classic.

4
00:15.770 --> 00:22.340
So the classic version of higher lower is you compare one search term, "The Grand Budapest Hotel" which

5
00:22.340 --> 00:27.920
is a movie against another search term, "AFL", which is the Australian Football League.

6
00:27.920 --> 00:35.190
And you have to say if the second one has higher or lower searches than The Grand Budapest Hotel.

7
00:35.190 --> 00:37.170
So I think this probably has higher,

8
00:37.380 --> 00:39.450
and indeed I'm right.

9
00:39.630 --> 00:42.660
And now it gives you a new term to compare.

10
00:42.720 --> 00:47.250
So "Six Nations" Rugby versus "AFL", who has lower?

11
00:47.250 --> 00:48.870
I think this probably has lower,

12
00:48.870 --> 00:53.520
and I'm right. And you keep going until you get it wrong.

13
00:53.520 --> 00:56.830
And it's a weirdly addictive game for some reason.

14
00:57.250 --> 01:04.180
Okay, so now I've gotten it wrong and it tells me how many I got right as my score, and I can play again

15
01:04.180 --> 01:10.720
if I wish to. Have a play around with that game, because the final version we have looks a lot simpler,

16
01:10.720 --> 01:13.300
but it's still just as fun to play.

17
01:13.480 --> 01:20.630
Instead of comparing average monthly searches on Google, we're comparing who has more followers on

18
01:20.630 --> 01:21.440
Instagram.

19
01:21.440 --> 01:23.630
So we're bringing this game up to date.

20
01:23.720 --> 01:29.720
In this case, it's comparing Neymar, a footballer from Brazil, against Khloe Kardashian, a reality

21
01:29.720 --> 01:34.550
TV personality and businesswoman from the US who has more followers.

22
01:34.550 --> 01:39.560
So I think it's 'B', I could be wrong and I'm wrong.

23
01:42.500 --> 01:49.650
So here we're comparing Rihanna, a musician and businesswoman from Barbados, against Shakira, a musician

24
01:49.650 --> 01:50.520
from Colombia.

25
01:50.550 --> 01:53.310
So I'm going to guess probably Rihanna,

26
01:53.460 --> 01:54.780
and I get it right.

27
01:54.780 --> 02:02.970
So I get to score one point and this game continues on and on, until you get to the point where you get

28
02:02.970 --> 02:05.700
it wrong, same as the one that you saw before.

29
02:06.600 --> 02:07.650
And there we go.

30
02:07.660 --> 02:10.300
So I got 3 as my final score,

31
02:10.300 --> 02:12.940
and that's the end of the game.

32
02:13.180 --> 02:19.750
The aim of the game is to try and stay alive for as long as possible, and score as high as possible

33
02:19.750 --> 02:23.530
by thinking about who might be more popular than the other.

34
02:23.830 --> 02:25.690
Now here comes the interesting part,

35
02:25.690 --> 02:29.950
you're going to be coding up this game entirely by yourself.

36
02:30.040 --> 02:36.770
You're going to apply everything you've learned so far to understand how this game works by playing

37
02:36.770 --> 02:42.740
it quite a few times, going to this URL, and looking at all the specific nuances.

38
02:42.740 --> 02:44.270
What happens if you get it wrong?

39
02:44.270 --> 02:50.480
What happens if you get it right? And you're going to write the code all yourself, and you're probably

40
02:50.480 --> 02:55.940
going to need your skills of debugging to fix some problems as you go along as well.

41
02:56.060 --> 03:02.760
So the approach that I want you to take is first, think about the problem and then break down a large

42
03:02.760 --> 03:05.250
problem into smaller problems.

43
03:05.250 --> 03:10.200
This way you can tackle them one by one and it won't be so intimidating.

44
03:10.200 --> 03:15.870
Now step two, is to look at those problems and make a TODO list.

45
03:15.870 --> 03:22.510
Given the items on the TODO list, you're going to pick the one that you think is the easiest to begin.

46
03:22.600 --> 03:26.860
Let's say that maybe generating a random number.

47
03:26.860 --> 03:28.390
That's pretty simple, right?

48
03:28.390 --> 03:32.050
Well, in this to do list, that's the first one we're going to tackle.

49
03:32.170 --> 03:35.710
So in this case we're building a very simple dice game.

50
03:35.710 --> 03:36.070
Right?

51
03:36.070 --> 03:38.710
The game that you're going to be building is a lot more complex,

52
03:38.710 --> 03:41.650
it won't just have three to dos, but the idea is the same.

53
03:41.650 --> 03:44.980
Once you pick the task that you think is the easiest,

54
03:44.980 --> 03:50.350
generating a random number, then you're going to take that problem and you're going to break it down

55
03:50.350 --> 03:52.600
into comments in your code.

56
03:52.600 --> 03:58.360
So just as you've seen me do it for our previous projects, you're going to do the same thing.

57
03:58.360 --> 04:04.270
You're going to take that problem of generating a random number and then split it into different pieces.

58
04:04.270 --> 04:04.660
Right?

59
04:04.660 --> 04:09.850
First you probably have to import the random module, and then you probably have to use a function like

60
04:09.860 --> 04:12.560
randint() to generate a random integer.

61
04:12.770 --> 04:19.520
So now that you've taken a big problem and broken it apart into smaller problems, taken the easiest,

62
04:19.520 --> 04:25.310
smaller problem and break it down into comments in your code, then you're ready to start writing some

63
04:25.310 --> 04:25.850
code.

64
04:26.360 --> 04:29.540
So write code beneath the comments.

65
04:29.540 --> 04:35.290
Run your code, make sure that it does what you want it to do, and if it doesn't, then fix the code.

66
04:35.290 --> 04:37.930
And once you've done that, then it's back to the beginning,

67
04:37.930 --> 04:40.030
write more code under the comments,

68
04:40.030 --> 04:41.140
run more code,

69
04:41.140 --> 04:46.030
fix more code until you've managed to cross out that task.

70
04:46.030 --> 04:50.260
And then it's a case of tackling the next one that you think you can attempt.

71
04:50.260 --> 04:56.500
So this is the real skill of programmers taking something that's immensely complex and difficult, breaking

72
04:56.500 --> 05:01.840
it down into smaller problems, breaking it down further and then tackling them from the easiest to

73
05:01.840 --> 05:04.480
the hardest, and doing this one by one.

74
05:04.480 --> 05:08.380
Eventually, by the end, you end up with your final product.

75
05:08.380 --> 05:10.630
This is what I want you to do.

76
05:10.630 --> 05:16.810
So the first thing you are to do is to head over to the final version of the game, play it at least

77
05:16.810 --> 05:20.350
ten times just so you understand exactly how it works.

78
05:20.470 --> 05:25.100
Now you'll notice that there's three files in the starting code.

79
05:25.100 --> 05:33.440
One is the art.py that contains the logo and the versus symbol that shows up when it asks you to compare.

80
05:34.040 --> 05:38.750
So compare 'A' Cristiano Ronaldo versus 'B' Vin Diesel.

81
05:38.750 --> 05:41.120
And these are the art that you're going to display.

82
05:41.120 --> 05:46.040
And finally, and probably most importantly there is a file called game_data.

83
05:46.070 --> 05:49.890
Now game_data only contains a single variable.

84
05:49.890 --> 05:54.120
It's a list of dictionary entries.

85
05:54.210 --> 06:00.480
Each of these dictionaries have four keys, and the keys are the same for all of the entries.

86
06:00.480 --> 06:04.740
They've got a 'name', the name of the account, the follower_count,

87
06:04.740 --> 06:09.060
so how many followers in millions does that account have?

88
06:09.090 --> 06:15.940
So for example, Cristiano Ronaldo has 215 million followers, at least at the time when I compiled

89
06:15.940 --> 06:16.750
the data.

90
06:16.750 --> 06:19.030
And then it has a description,

91
06:19.030 --> 06:20.200
he's a footballer,

92
06:20.230 --> 06:22.450
or this is a social media platform,

93
06:22.450 --> 06:24.280
she's a musician and actress,

94
06:24.280 --> 06:30.040
and finally, the country that they're from. You're going to use all these pieces of information to

95
06:30.040 --> 06:33.340
construct a comparison line like this,

96
06:33.340 --> 06:40.640
"Compare A: Cristiano Ronaldo, a footballer from Portugal with B..." and you're going to ask the user to guess

97
06:40.640 --> 06:48.380
who has more followers, and if they get it right, they get to keep playing, where A now becomes the previous

98
06:48.410 --> 06:48.860
B.

99
06:49.040 --> 06:57.590
So Vin Diesel, who used to be B, now becomes A, and then you get to compare against a new person

100
06:57.590 --> 07:01.070
and it keeps on going until they get it wrong.

101
07:01.550 --> 07:07.590
That is the task ahead of you, and it's not going to be easy, but I think you can do it.

102
07:07.590 --> 07:10.350
So give this project at least an hour.

103
07:10.350 --> 07:11.970
You'll need to write the code,

104
07:11.970 --> 07:13.290
you'll need to fix problems,

105
07:13.290 --> 07:14.430
you'll need to debug,

106
07:14.430 --> 07:20.610
you'll need to test it quite a few times, but by the end of it you will emerge a stronger programmer,

107
07:20.610 --> 07:21.420
I promise.

108
07:21.420 --> 07:27.180
So good luck and make sure you have lots of struggle and I'll see you on the other side.