All right.
Let's talk about the mechanics and the program requirements for the blackjack game that you'll create.
For those of you who are not familiar with the game of blackjack, also known as 21.
I'm just going to spend a few minutes to go through the rules with you.
Blackjack is a game that's played using cards, and the goal of the game is to add up your cards to
the largest number without going over 21.
If the cards in your hand add up to more than 21, then it's called a bust, and it means that you lose
immediately.
And it doesn't matter how much you've gone over 21, as long as it's over 21, then you lose.
Now, the way that the cards are counted is that all the cards from 2 to 10 count as their face value.
So a six is a six, a nine is a nine, etc. but the Jack, Queen and king each count as ten, and the
other special card is the ace.
Now the ace can either count as a one towards your total, or it can count as an 11.
And depending on whether if you've gone over 21 or whether if you're under 21, you can decide which
value you want your ace to represent.
Let's play a sample game.
Let's say that the dealer over here got a ten to begin with, and you got a queen, which also counts
as a ten to begin with.
So these are the first cards that are dealt.
And both of these cards are revealed.
And then the dealer deals another card to each of you.
Now the dealer's second hand is concealed so you can't work out what their total is.
But you can see your own card.
So at the moment we don't know what the dealer has.
It might be ten plus anything, but we know that our score is 13, ten plus three.
At this point, you might ask the dealer for another card.
So now you have three cards and luckily it adds up to 20 without going over 21.
But there is also a possibility that you might have gotten a card that would have pushed your total
over 21, at which point you now lose.
And it doesn't matter what the dealer has in their hand.
You've already lost because you've gone over 21.
Now let's say that we got lucky and our total adds up to 20.
Now, at this point, we say we don't want any more cards and the dealer reveals their hand.
If, like in this case, they end up with 20 and we have 20, then we end up in a draw.
So whenever your score equals the dealer score, then you will draw rather than win or lose.
Now if on the other hand, the dealer ended up with an ace, which we know can count as an 11 and they
actually scored higher than us, they have 21 and we have 20.
Well, in this case we would lose.
Now the rules also state that if the dealer ends up with a hand that's smaller than 17, so 16 or under.
Then they must take another card.
Those are the basic rules of blackjack, but I recommend that before you get started, head over to
the link that's in the blackjack starting file and have a few games of blackjack just so that you can
see for yourself how it actually works and how you win and how you lose.
And then head over to the final version of the completed project and play our simplified version of
blackjack.
This way you'll see what the end result is that you're trying to create, and it will be easier when
you're creating the code yourself.
Now, as I mentioned, we're going to try and keep our version of blackjack a little bit simpler.
And we're going to assume a couple of things.
The first thing is that the cards that we're starting with comes from this list.
You'll notice that I've got two through to ten all represented in the list.
And then I've got Jack, Queen and King represented as tens as well.
So this means that the ten has four times the probability of occurring compared to the other cards.
Now the ace is going to start off being represented as 11, and it's going to count as 11 until the
user goes over 21.
Now finally we're going to assume that we have an infinite deck.
So it means that when a card is drawn from the deck, it's not removed from the deck.
Whereas in a real casino they have maybe 6 or 8 decks of cards.
When a card is drawn, then there's less probability of that same card occurring again.
And this is how professional card counters the people that the casinos hate the most actually go about
trying to optimize and improve their chances.
But in order to keep things simple in our game, we're not going to deal with things regarding probability
or removing cards from the deck.
We're going to assume that each of these cards in the list have equal chance of occurring.
If you head over to the starting project, you'll see each of these rules written out in more detail.
Take a look at it so that you're aware what our house rules dictate.
Now, if you scroll to the very top of the blackjack project, I've given you four tracks.
So just as when you start a video game, you have the choice of normal, hard, extra hard, or expert.
It's the same in this project.
You can limit yourself to using only one hint.
If you are at expert level in Python, you can only use hint one and two.
If you want an extra hard challenge and maybe a little bit of a cry at the end, there's also hard and
normal, so I'll leave the choice up to you.
And if you scroll down you'll find all the hints listed in here.
Now I recommend everybody, no matter your experience, everybody should try out the blackjack game.
And also look at how the final project is supposed to work.
But then I've got other things, such as a list where I've broken down the program requirements.
You know how we always say when you have a big problem, always try to break it down into smaller pieces?
Now you can of course, create this list yourself by exploring the game, exploring the final project,
and then writing your own to do list of things that need to be coded up.
Or alternatively, you can look at the one that I've created inside.
Hint two.
Inside hint three I've created a flowchart for you, which takes the to do list and breaks it down into
a flowchart where you can look at the logic in more detail.
Now, of course, as always, it's a good idea to create your own flowchart using a tool like Draw.io
or using a piece of pen and paper.
But if you need help, it's there for you and you can download the PDF and read through it.
Now the rest of the hints will go through how to solve this project in even smaller, bite sized chunks,
depending on your own level of Python at the moment, choose your own difficulty level.
But I just want to say before you get started that this project is difficult, and I wanted to give
you a bit of a challenge and to push yourself so that you get stronger.
But there will inevitably be moments where you will have doubt and you will be wondering, what am I
doing?
I don't understand anything, and in this moment, I want you to look yourself in the mirror and tell
yourself that you got this.
You can do it and that.
Remember that I'm here rooting for you.
I believe you can do it.
You've got everything that you've learned so far will enable you to do it.
There's nothing new in this challenge.
You just have to put all the pieces together.
You have to push through the difficult parts and maybe sleep on a problem and think about it and then
come back to it.
But I believe you can do it.
Once you're ready, pause the video, head over to the starting project and give it a go.
And once you're satisfied, then head over to the next lesson and I'll walk through the solution with
you.