WEBVTT

00:00.140 --> 00:00.590
All right.

00:00.590 --> 00:05.330
Let's talk about the mechanics and the program requirements for the blackjack game that you'll create.

00:05.330 --> 00:10.310
For those of you who are not familiar with the game of blackjack, also known as 21.

00:10.340 --> 00:13.580
I'm just going to spend a few minutes to go through the rules with you.

00:13.760 --> 00:21.290
Blackjack is a game that's played using cards, and the goal of the game is to add up your cards to

00:21.320 --> 00:25.310
the largest number without going over 21.

00:26.180 --> 00:34.010
If the cards in your hand add up to more than 21, then it's called a bust, and it means that you lose

00:34.010 --> 00:35.180
immediately.

00:35.300 --> 00:41.780
And it doesn't matter how much you've gone over 21, as long as it's over 21, then you lose.

00:42.230 --> 00:49.850
Now, the way that the cards are counted is that all the cards from 2 to 10 count as their face value.

00:49.850 --> 00:58.850
So a six is a six, a nine is a nine, etc. but the Jack, Queen and king each count as ten, and the

00:58.850 --> 01:01.040
other special card is the ace.

01:01.070 --> 01:08.220
Now the ace can either count as a one towards your total, or it can count as an 11.

01:08.250 --> 01:14.970
And depending on whether if you've gone over 21 or whether if you're under 21, you can decide which

01:14.970 --> 01:17.580
value you want your ace to represent.

01:18.090 --> 01:19.710
Let's play a sample game.

01:19.740 --> 01:27.990
Let's say that the dealer over here got a ten to begin with, and you got a queen, which also counts

01:27.990 --> 01:29.400
as a ten to begin with.

01:29.430 --> 01:32.160
So these are the first cards that are dealt.

01:32.160 --> 01:35.010
And both of these cards are revealed.

01:35.070 --> 01:39.210
And then the dealer deals another card to each of you.

01:39.240 --> 01:44.970
Now the dealer's second hand is concealed so you can't work out what their total is.

01:44.970 --> 01:47.400
But you can see your own card.

01:47.400 --> 01:50.670
So at the moment we don't know what the dealer has.

01:50.670 --> 01:58.050
It might be ten plus anything, but we know that our score is 13, ten plus three.

01:59.280 --> 02:03.090
At this point, you might ask the dealer for another card.

02:03.090 --> 02:10.270
So now you have three cards and luckily it adds up to 20 without going over 21.

02:10.780 --> 02:16.660
But there is also a possibility that you might have gotten a card that would have pushed your total

02:16.660 --> 02:20.170
over 21, at which point you now lose.

02:20.170 --> 02:23.200
And it doesn't matter what the dealer has in their hand.

02:23.230 --> 02:26.200
You've already lost because you've gone over 21.

02:26.740 --> 02:31.540
Now let's say that we got lucky and our total adds up to 20.

02:31.570 --> 02:37.660
Now, at this point, we say we don't want any more cards and the dealer reveals their hand.

02:37.840 --> 02:45.340
If, like in this case, they end up with 20 and we have 20, then we end up in a draw.

02:45.340 --> 02:52.390
So whenever your score equals the dealer score, then you will draw rather than win or lose.

02:52.720 --> 02:59.770
Now if on the other hand, the dealer ended up with an ace, which we know can count as an 11 and they

02:59.770 --> 03:04.480
actually scored higher than us, they have 21 and we have 20.

03:04.510 --> 03:06.820
Well, in this case we would lose.

03:07.420 --> 03:16.610
Now the rules also state that if the dealer ends up with a hand that's smaller than 17, so 16 or under.

03:16.640 --> 03:19.400
Then they must take another card.

03:19.790 --> 03:26.150
Those are the basic rules of blackjack, but I recommend that before you get started, head over to

03:26.180 --> 03:32.540
the link that's in the blackjack starting file and have a few games of blackjack just so that you can

03:32.540 --> 03:37.430
see for yourself how it actually works and how you win and how you lose.

03:37.760 --> 03:46.790
And then head over to the final version of the completed project and play our simplified version of

03:46.790 --> 03:47.810
blackjack.

03:48.020 --> 03:54.200
This way you'll see what the end result is that you're trying to create, and it will be easier when

03:54.200 --> 03:56.030
you're creating the code yourself.

03:56.060 --> 04:01.940
Now, as I mentioned, we're going to try and keep our version of blackjack a little bit simpler.

04:02.210 --> 04:04.640
And we're going to assume a couple of things.

04:04.670 --> 04:10.040
The first thing is that the cards that we're starting with comes from this list.

04:10.100 --> 04:15.080
You'll notice that I've got two through to ten all represented in the list.

04:15.080 --> 04:19.850
And then I've got Jack, Queen and King represented as tens as well.

04:19.850 --> 04:27.320
So this means that the ten has four times the probability of occurring compared to the other cards.

04:27.380 --> 04:34.640
Now the ace is going to start off being represented as 11, and it's going to count as 11 until the

04:34.640 --> 04:36.470
user goes over 21.

04:36.740 --> 04:41.210
Now finally we're going to assume that we have an infinite deck.

04:41.210 --> 04:46.220
So it means that when a card is drawn from the deck, it's not removed from the deck.

04:46.250 --> 04:51.170
Whereas in a real casino they have maybe 6 or 8 decks of cards.

04:51.170 --> 04:57.470
When a card is drawn, then there's less probability of that same card occurring again.

04:57.470 --> 05:03.890
And this is how professional card counters the people that the casinos hate the most actually go about

05:03.890 --> 05:06.890
trying to optimize and improve their chances.

05:06.890 --> 05:13.040
But in order to keep things simple in our game, we're not going to deal with things regarding probability

05:13.040 --> 05:15.230
or removing cards from the deck.

05:15.260 --> 05:20.660
We're going to assume that each of these cards in the list have equal chance of occurring.

05:21.150 --> 05:27.810
If you head over to the starting project, you'll see each of these rules written out in more detail.

05:27.840 --> 05:31.800
Take a look at it so that you're aware what our house rules dictate.

05:32.460 --> 05:38.070
Now, if you scroll to the very top of the blackjack project, I've given you four tracks.

05:38.130 --> 05:45.180
So just as when you start a video game, you have the choice of normal, hard, extra hard, or expert.

05:45.210 --> 05:47.220
It's the same in this project.

05:47.250 --> 05:50.850
You can limit yourself to using only one hint.

05:50.850 --> 05:56.550
If you are at expert level in Python, you can only use hint one and two.

05:56.580 --> 06:04.650
If you want an extra hard challenge and maybe a little bit of a cry at the end, there's also hard and

06:04.650 --> 06:07.440
normal, so I'll leave the choice up to you.

06:07.440 --> 06:11.520
And if you scroll down you'll find all the hints listed in here.

06:11.550 --> 06:17.760
Now I recommend everybody, no matter your experience, everybody should try out the blackjack game.

06:17.760 --> 06:21.960
And also look at how the final project is supposed to work.

06:21.960 --> 06:28.870
But then I've got other things, such as a list where I've broken down the program requirements.

06:28.900 --> 06:34.720
You know how we always say when you have a big problem, always try to break it down into smaller pieces?

06:34.750 --> 06:41.860
Now you can of course, create this list yourself by exploring the game, exploring the final project,

06:41.860 --> 06:46.120
and then writing your own to do list of things that need to be coded up.

06:46.120 --> 06:50.200
Or alternatively, you can look at the one that I've created inside.

06:50.200 --> 06:50.980
Hint two.

06:51.490 --> 06:59.050
Inside hint three I've created a flowchart for you, which takes the to do list and breaks it down into

06:59.050 --> 07:02.980
a flowchart where you can look at the logic in more detail.

07:03.010 --> 07:09.550
Now, of course, as always, it's a good idea to create your own flowchart using a tool like Draw.io

07:09.580 --> 07:11.650
or using a piece of pen and paper.

07:11.650 --> 07:17.230
But if you need help, it's there for you and you can download the PDF and read through it.

07:17.440 --> 07:24.610
Now the rest of the hints will go through how to solve this project in even smaller, bite sized chunks,

07:24.640 --> 07:30.800
depending on your own level of Python at the moment, choose your own difficulty level.

07:30.800 --> 07:37.460
But I just want to say before you get started that this project is difficult, and I wanted to give

07:37.460 --> 07:42.350
you a bit of a challenge and to push yourself so that you get stronger.

07:42.350 --> 07:48.740
But there will inevitably be moments where you will have doubt and you will be wondering, what am I

07:48.740 --> 07:49.250
doing?

07:49.250 --> 07:53.840
I don't understand anything, and in this moment, I want you to look yourself in the mirror and tell

07:53.840 --> 07:55.190
yourself that you got this.

07:55.190 --> 07:56.990
You can do it and that.

07:56.990 --> 07:59.660
Remember that I'm here rooting for you.

07:59.660 --> 08:01.010
I believe you can do it.

08:01.010 --> 08:05.090
You've got everything that you've learned so far will enable you to do it.

08:05.090 --> 08:08.000
There's nothing new in this challenge.

08:08.000 --> 08:10.580
You just have to put all the pieces together.

08:10.580 --> 08:16.340
You have to push through the difficult parts and maybe sleep on a problem and think about it and then

08:16.340 --> 08:17.300
come back to it.

08:17.300 --> 08:19.130
But I believe you can do it.

08:19.160 --> 08:26.150
Once you're ready, pause the video, head over to the starting project and give it a go.

08:26.750 --> 08:31.850
And once you're satisfied, then head over to the next lesson and I'll walk through the solution with

08:31.850 --> 08:32.300
you.
