Hey, guys.
Welcome to Day 14 of 100 Days of Code.
Today you're going to spend building a exciting game called Higher or Lower.
And if you want to have a go at it just go over to higherlowergame.com and click on Classic.
So the classic version of higher lower is you compare one search term, "The Grand Budapest Hotel" which
is a movie against another search term, "AFL", which is the Australian Football League.
And you have to say if the second one has higher or lower searches than The Grand Budapest Hotel.
So I think this probably has higher,
and indeed I'm right.
And now it gives you a new term to compare.
So "Six Nations" Rugby versus "AFL", who has lower?
I think this probably has lower,
and I'm right. And you keep going until you get it wrong.
And it's a weirdly addictive game for some reason.
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
if I wish to. Have a play around with that game, because the final version we have looks a lot simpler,
but it's still just as fun to play.
Instead of comparing average monthly searches on Google, we're comparing who has more followers on
Instagram.
So we're bringing this game up to date.
In this case, it's comparing Neymar, a footballer from Brazil, against Khloe Kardashian, a reality
TV personality and businesswoman from the US who has more followers.
So I think it's 'B', I could be wrong and I'm wrong.
So here we're comparing Rihanna, a musician and businesswoman from Barbados, against Shakira, a musician
from Colombia.
So I'm going to guess probably Rihanna,
and I get it right.
So I get to score one point and this game continues on and on, until you get to the point where you get
it wrong, same as the one that you saw before.
And there we go.
So I got 3 as my final score,
and that's the end of the game.
The aim of the game is to try and stay alive for as long as possible, and score as high as possible
by thinking about who might be more popular than the other.
Now here comes the interesting part,
you're going to be coding up this game entirely by yourself.
You're going to apply everything you've learned so far to understand how this game works by playing
it quite a few times, going to this URL, and looking at all the specific nuances.
What happens if you get it wrong?
What happens if you get it right? And you're going to write the code all yourself, and you're probably
going to need your skills of debugging to fix some problems as you go along as well.
So the approach that I want you to take is first, think about the problem and then break down a large
problem into smaller problems.
This way you can tackle them one by one and it won't be so intimidating.
Now step two, is to look at those problems and make a TODO list.
Given the items on the TODO list, you're going to pick the one that you think is the easiest to begin.
Let's say that maybe generating a random number.
That's pretty simple, right?
Well, in this to do list, that's the first one we're going to tackle.
So in this case we're building a very simple dice game.
Right?
The game that you're going to be building is a lot more complex,
it won't just have three to dos, but the idea is the same.
Once you pick the task that you think is the easiest,
generating a random number, then you're going to take that problem and you're going to break it down
into comments in your code.
So just as you've seen me do it for our previous projects, you're going to do the same thing.
You're going to take that problem of generating a random number and then split it into different pieces.
Right?
First you probably have to import the random module, and then you probably have to use a function like
randint() to generate a random integer.
So now that you've taken a big problem and broken it apart into smaller problems, taken the easiest,
smaller problem and break it down into comments in your code, then you're ready to start writing some
code.
So write code beneath the comments.
Run your code, make sure that it does what you want it to do, and if it doesn't, then fix the code.
And once you've done that, then it's back to the beginning,
write more code under the comments,
run more code,
fix more code until you've managed to cross out that task.
And then it's a case of tackling the next one that you think you can attempt.
So this is the real skill of programmers taking something that's immensely complex and difficult, breaking
it down into smaller problems, breaking it down further and then tackling them from the easiest to
the hardest, and doing this one by one.
Eventually, by the end, you end up with your final product.
This is what I want you to do.
So the first thing you are to do is to head over to the final version of the game, play it at least
ten times just so you understand exactly how it works.
Now you'll notice that there's three files in the starting code.
One is the art.py that contains the logo and the versus symbol that shows up when it asks you to compare.
So compare 'A' Cristiano Ronaldo versus 'B' Vin Diesel.
And these are the art that you're going to display.
And finally, and probably most importantly there is a file called game_data.
Now game_data only contains a single variable.
It's a list of dictionary entries.
Each of these dictionaries have four keys, and the keys are the same for all of the entries.
They've got a 'name', the name of the account, the follower_count,
so how many followers in millions does that account have?
So for example, Cristiano Ronaldo has 215 million followers, at least at the time when I compiled
the data.
And then it has a description,
he's a footballer,
or this is a social media platform,
she's a musician and actress,
and finally, the country that they're from. You're going to use all these pieces of information to
construct a comparison line like this,
"Compare A: Cristiano Ronaldo, a footballer from Portugal with B..." and you're going to ask the user to guess
who has more followers, and if they get it right, they get to keep playing, where A now becomes the previous
B.
So Vin Diesel, who used to be B, now becomes A, and then you get to compare against a new person
and it keeps on going until they get it wrong.
That is the task ahead of you, and it's not going to be easy, but I think you can do it.
So give this project at least an hour.
You'll need to write the code,
you'll need to fix problems,
you'll need to debug,
you'll need to test it quite a few times, but by the end of it you will emerge a stronger programmer,
I promise.
So good luck and make sure you have lots of struggle and I'll see you on the other side.