INTRODUCTION
If you have any idea about poker or gambling, you might've surely come
across this beautiful game of blackjack.
Blackjack is one of the simplest poker games and one of the most
predictable and played widely across the globe.
It is a perfect game for a beginner who wants to get into casinos or
gambling (gambling could be dangerous, please don't gamble and even if you
do, please make sure you know what you're doing)
Anyway, back to blackjack.
I watch a lot of movies which includes movies like 21, now you see me,
ocean's eleven etc and they all revolve around cardistry and poker.
A few years ago, I learnt a lot about cardistry, false shuffles, card
jumping and a lot of card tricks, just for fun.
Then I got attracted towards card games like blackjack.
Let's go over the rules of blackjack once..
RULES
Blackjack is played against the dealer, the dealer shuffles a deck(52) of
cards, and deals out 2 cards to the player face up(so that you could view
your card) and deals for themselves.
You need to check the sum of the values of your cards ( from 2, 10), the
face cards(jack, queen and king) have the value of 10 and the ace could be
either 1 or 11 according to your need.
Your sum should not exceed 21, if it does, it's a bust.
If the sum given to you is low, then you can hit and ask for another card,
and if you think the sum of your card is high enough, you can stand and
place your bets.
The bet is placed on whether your sum is higher or the dealer's.
If your sum is higher than the dealer without busting, you win the round
and the bet and if your sum is lower then the dealer, the dealer wins the
game.
You win by default, if the dealer busts.
Well there are a lot more rules to it, but you just need to know all
these.
CODING BLACKJACK
I like coding stuff, so I decided to code the game. I use a card pack asset
and named the cards according to their values.
The code turned out to be smooth and working and it worked really
good.
Let's test the code:
I was initially dealt a 4 and a jack which means my sum was 14, i
wasnt quite satisfied with my sum as the dealer's card totalled up to
20.
I hit and take another card until I get satisfied with my sum:
As my sum is 16 I feel confident about my sum and I stand as I assume
that the dealer might bust.
And here it goes, I win the round as the dealer busted
BASIC BLACKJACK STRATEGY AND CARD COUNTING
There are many ways to win in blackjack, one of the most important way
is to follow the basic strategy of blackjack.
The basic strategy of blackjack is a table which mentions what to do and
what would be the ideal choice if we have a particular set of sums.
As I have coded a 1 deck game, here's a 1 deck basic blackjack strategy:
On the left side,we have our sum and on the top we have the dealer's
sum.
The yellow box(S) suggest that we should stand, and the red(H) box
suggest we should hit.
The blue box(DH) suggest that we should double our bets and hit but
since I haven't coded a bet system in my game, I consider it as a hit.
But I want to get better at blackjack, so I tried to implement this
table in my code as a helper, so I get a good amount of practise.
I added the following function in my code:
I get dealt with an ace and a 3, my sum becomes wither 4 or 14. And the helper code suggested me to hit and that's what I will be doing.
I got a 7, which makes my sum 21, as this is a natural blackjack, the helper code asks me to stand and I will listen to the code.
Ha! this was a close one but the helper code helped me win anyway..
There's a lot more that I wanted to go through, like the martingale betting system and card counting.
But I cannot technically code that, or maybe I will but some time later.
Anyway, I hope you had a good read, you can find the code for this game here.
Have a nice day!!
Comments
Post a Comment