Introduction

  1. You can click the menu button on the top right corner to read the rules. What's best: We also automatically save your game so you can come back anytime to play blackjack online! Remember, you don't win because you are closer to the value of 21 - you win because your combined value of the cards is greater than that of dealer. Blackjack Strategy.
  2. The basic rules of blackjack are simple. Players try to score as close to 21 as possible without exceeding 21. In contrast to poker, where players compete with each other, blackjack is a one-on-one game between each player and the dealer. As the dealer, the basic rules of blackjack still apply. Cards 2 through 10 are worth their face value.

The North American game of Blackjack, also known as 21, has been one of the most popular casino games of the last hundred years and has spread throughout the world. In the 21st century it has been overtaken in popularity by Slots (slot machine games), but it remains one of the most popular casino card games and is available in almost all casinos both on and offline.

Blackjack is a casino banked game, meaning that players compete against the house rather than each other. The objective is to get a hand total of closer to 21 than the dealer without going over 21 (busting).

At the start of a Blackjack game, the players and the dealer receive two cards each. The players' cards are normally dealt face up, while the dealer has one face down (called the hole card) and one face up. The best possible Blackjack hand is an opening deal of an ace with any ten-point card.

The house advantage of this game is derived from several rules that favour the dealer. The most significant of these is that the player must act before the dealer, allowing the player to bust and lose their bet before the dealer plays.

Rules of Blackjack. If you already know how to play Blackjack, skip to the 'Modeling the Game' section below. Blackjack is a casino-style card game in which the player(s) attempt to beat a dealer's score while getting as close to 21 points as possible, without going over. It is played with a standard four-suit, 52-card deck.

Players should be aware that there is another card game called Black Jack in the UK which is an entirely different card game, effectively the same as Crazy Eights.

Note. Gambling can be dangerously addictive. You can find information and advice on our Responsible Gambling page.

We would like to thank the following partner sites for their support:

An overview of casinos that offer Online Blackjack in Australia is available at onlinecasino-australia.com, which has been recommending reliable online casinos to Australian players since 2016.

Information about Online Blackjack in South Africa and its different variations can be found at onlinecasino-southafrica.co.za, which since 2017 has provided advice on gambling options using South African currency.

Dedicated to providing accurate information about online gambling and the legal aspects involved since 2015, John Isaac's team at online-gambling.com have produced a plethora of online blackjack resources for players.

Equipment

Blackjack is played with a standard international deck of cards with the Jokers removed, leaving 52 cards. Originally the game was played with a single deck. However, as a counter measure to card counting, casinos introduced multi-deck games, based on the false assumption that if there were more cards in play it would be harder for the card counter to keep track of them all. As a result, Blackjack is now usually offered in either single deck, double deck, 4 deck, 6 deck or 8 deck variants. It should be noted that there are exceptions in online casinos where far larger numbers of decks can be used than would be practical to manage offline.

Aside from the cards, the game requires a table, chips, a discard tray, cut card and a shoe.

After the dealer has shuffled a player will be selected at random and asked to take the cut card – a coloured plastic card matching the playing cards in size – and place it at a random position within stack of cards. The dealer will then move the cards above the cut card to the back of the stack. This technique is intended to demonstrate to the players that the dealer cannot have rigged the deck. The cut card is then reinserted into the stack of cards by the dealer at a pre-defined position and when this card is reached this indicates the final deal of the game before the cards are shuffled.

Blackjack 21 Dealer Rules

Where multiple decks are used, after the shuffle the cards will be placed into a dispenser called a shoe. This piece of equipment has two purposes: to hold large stacks of cards in multi-deck games and make the practice of hole carding (cheating by catching a glimpse of the dealer’s hole card) more difficult. In fact hole carding is not illegal in the vast majority of jurisdictions. If the dealer is poorly trained or sloppy enough to fail to protect their down card from being seen by a player at the table this is not the player's fault and the player is not obliged to look away to prevent themselves seeing the down card. If however the player uses any form of device, for instance a metal lighter to observe the reflection in, or an accomplice off table signals the information to them, this is cheating. Hole carding is only legal where the player can see the card naturally from one of the player positions at the table.

Card Values

When playing Blackjack the numeral cards 2 to 10 have their face values, Jacks, Queens and Kings are valued at 10, and Aces can have a value of either 1 or 11. The Ace is always valued at 11 unless that would result in the hand going over 21, in which case it is valued as 1.

Any hand with an Ace valued as 11 is called a ‘soft’ hand. All other hands are ‘hard’ hands.

A starting hand of a 10 valued card and an Ace is called a Blackjack or natural and beats all hands other than another Blackjack. If both the player and dealer have Blackjack, the result is a push (tie): neither the player nor the bank wins and the bet is returned to the player.

Order of Play and Playing Options

Each player sitting at the table places their desired bet in the betting circle directly in front of them. In most casinos if there are untaken betting circles, the players sitting at the table can choose to play more than one hand at a time. The minimum and maximum bet size varies from casino to casino, generally with a ratio of 40 to 100 between them. For example with a $25 minimum bet the maximum will usually be somewhere from $1000 to $2500. Once the bets are placed the dealer will move their hand across the table from their left to their right signalling that no further bets can be placed. The dealer then deals cards one at a time clockwise around the table, from the dealer's left to the dealer's right: first a card face up to each betting circle that has a bet in it, then a card face up to the dealer, and then a second card face up to each betting circle with a bet and finally a second card face down to the dealer.

In many places the dealer's first card is initially dealt face down. The dealer's second card is used to flip the first card face up and then slid underneath the first card. The exact dealing protocol varies from place to place as determined by the casino management.

If the dealer has a 10 or an Ace face up players are offered the option to place an Insurance bet. Insurance is a side bet on whether or not the dealer has a Blackjack, unrelated to the final outcome of the round. If a player chooses to take insurance they place an additional bet equal to half of their original bet. This insurance bet wins if the dealer has Blackjack.

The dealer now checks their down card to see if they have Blackjack. If they have Blackjack they expose their down card. The round is concluded and all players lose their original bet unless they also have Blackjack. If a player and the dealer each have Blackjack the result is a push and the player's bet is returned. Any insurance bets are paid out at 2:1.

If the dealer does not have Blackjack any insurance bets are lost and any players who have Blackjack are paid. It is then the turn of the remaining players to take their actions. Starting with the player sitting furthest to dealer's left they have the following options:

Stand – If the player is happy with the total they’ve been dealt they can stand, taking no further action and passing to the next player. The player can take this action after any of the other player actions as long as their hand total is not more than 21. The hand signal to Stand is waving a flat hand over the cards.

Hit – If the player wishes to take another card they signal to the dealer to by scratching the felt beside their hand or pointing to their hand. A single card is then played face up onto their hand. If the hand total is less than 21 the player can choose to Hit again or Stand. If the total is 21 the hand automatically stands. If the total is over 21 the hand is bust, the player’s bet is taken by the house and the turn to act passes to the next player.

Double Down – If the player considers they have a favourable hand, generally a total of 9, 10 or 11, they can choose to 'Double Down'. To do this they place a second wager equal to their first beside their first wager. A player who doubles down receives exactly one more card face up and is then forced to stand regardless of the total. This option is only available on the player's two-card starting hand. Some casinos will restrict which starting hand totals can be doubled.

Split – If the player’s first two cards are of matching rank they can choose to place an additional bet equal to their original bet and split the cards into two hands. Where the player chooses to do this the cards are separated and an additional card is dealt to complete each hand. If either hand receives a second card of matching rank the player may be offered the option to split again, though this depends on the rules in the casino. Generally the player is allowed a maximum of 4 hands after which no further splits are allowed. The split hands are played one at a time in the order in which they were dealt, from the dealer's left to the dealer's right. The player has all the usual options: stand, hit or double down. Some casinos restrict the card ranks that can be split and may also restrict the option to Double after splitting a pair.

A player who splits Aces is usually only allowed to receive a single additional card on each hand. Normally players are allowed to split two non-matching 10-value cards, for example a King and a Jack. However, some casinos restrict the splitting of ten value cards to pairs of the same rank (two Jacks for instance). It should be noted in any case that splitting 10's is almost always a poor play for the player. If Aces are split and the player draws a Ten or if Tens are split and the player draws an Ace, the resulting hand does not count as a Blackjack but only as an ordinary 21. In this case the player's two-card 21 will push (tie with) dealer's 21 in three or more cards.

Surrender – Some casinos allow a player to surrender, taking back half their bet and giving up their hand. Surrender must be the player's first and only action on the hand. In the most usual version, known as Late Surrender, it is after the dealer has checked the hole card and does not have a Blackjack. It has become increasingly rare for casinos to offer the surrender option.

After all players have completed their actions the dealer plays their hand according to fixed rules. First they will reveal their down card. The dealer will then continue to take cards until they have a total of 17 or higher. The rules regarding Soft 17 (a total of 17 with an Ace counted as 11 such as A+6) vary from casino to casino. Some require the dealer to stand while others require additional cards to be taken until a total of hard 17 or 18+ is reached. This rule will be clearly printed on the felt of the table.
If the dealer busts all non-busted player hands are automatically winners.

Payouts

If the player and dealer have equal unbusted totals the hand is considered a push and the player’s bet is returned.

If a player wins a hand they are paid out at 1:1 on the total bet wagered on that hand. For example if the player wagered $10 and then doubled down placing a further bet of $10 on the hand and won, they would be paid a total of $40, their $20 bet back and $20 winnings.

If the player has Blackjack they are paid at 3:2, so that a wager of $10 the player would be paid a total of $25, their $10 bet back plus $15 winnings.

If the player has placed the Insurance bet and the dealer has Blackjack, the player’s hand loses but the Insurance bet is paid out at 2:1. So if the player had bet $10 on the hand and $5 on the Insurance bet, they would lose the $10 and be paid a total of $15 – their $5 Insurance bet returned and $10 winnings. This effectively results in a push overall for the hand.

Variants

Deal

In some casinos the players' initial two-card hands are dealt face down. All additional cards dealt to the player are given face up. The initial cards are revealed by the player if the hand goes bust, or if the player wishes to split a pair. Otherwise the dealer reveals the cards at the end of the round when it is time to settle the bets. This style of game is rare nowadays: casinos don't like to allow players to touch the cards, because of the risk of card marking.

In European style games only the dealer’s face up card is dealt at the start of the round. Dealer's second card is dealt after all players have acted, and the dealer checks for Blackjack at this point. Player Blackjacks are paid at the end of the round if the dealer does not have Blackjack. If the dealer has Blackjack the rules regarding Doubled and Split hands vary from casino to casino. Some casinos will take both bets while others will only take the initial bet and return the other.

Blackjack payout

It should be noted that some casinos have started to offer a reduced payout on Blackjack, most commonly 6:5. This is very bad for the player, increasing the House Edge significantly. Any game offering a reduced payout on Blackjack should be avoided by players.

Splits

The maximum number of hands that can be created by splitting depends on the rules in the casino: some only allow one split.

Blackjack 21 Dealer Rules

When splitting 10 value cards, not all casinos will allow players to split non-matching 10 cards. For instance, in some casinos you could split two Jacks but could not split a King and a Jack. Some casinos will limit which card ranks can be split, for example no splitting of 10s or splits only allowed on 8s and Aces.

House rules will dictate whether the player is allowed to Double after splitting, and whether a player who splits Aces is allowed to receive more than one additional card on a hand.

Surrender

Not all casinos offer the Surrender option.

A few casinos may offer Early Surrender in which the player can take back half of their bet and give up their hand before the dealer checks for Blackjack. This is very rare nowadays

In European style games there is normally no Surrender option. If Surrender were offered it would of course have to be Early Surrender.

Five Card Charlie

The side rule is rarely offered. When it is in effect, a player who collects a hand of five cards (two cards plus three hits) without going bust is immediately paid even money, irrespective of the dealer's hand.

Home game blackjack

Blackjack can be played at home, rather than in a casino. In this case a fancy Blackjack table is not needed: just at least one pack of cards and something to bet with - cash, chips or maybe matches. Unless the players have agreed in advance that the host should deal throughout, to ensure a fair game the participants should take turns to be the dealer. The turn to deal can pass to the next player in clockwise order after every hand or every five hands or whatever the players agree. If playing with a single deck of cards, it is desirable to re-shuffle the cards after every hand.

Swedish Pub Blackjack

Nightclubs and pubs in Sweden often offer a Blackjack variant that is less favourable to the players. All the essential rules are the same as in the casino version unless the player and dealer have an equal total of 17, 18 or 19. In the casino version the player's stake is returned in these situations, but in Swedish pubs the house wins.

Although pub stakes may vary, they are often much lower than in casinos with a minimum stake of 20 or 40 Krona and a maximum of 60 Krona (about US$7) for each hand.

Optimal Strategy

Basic Strategy table for one of the more commonly available rule combinations (6 decks, Resplit to 4 hands, Dealer Stands on Soft 17, Late Surrender, Double After Split).

First and foremost, as a general rule the player should never take Insurance. Unless using an advanced and mathematically proven strategy that will alert the player to the rare situations in which Insurance is worthwhile, it should be avoided as a bad bet for the player.

Next, it should be understood that every possible combination of player hands and dealer up card has a mathematically correct play. These can be summarized in what is known as a Basic Strategy table. However, certain plays in the table need to be modified according to the specific combination of rules in force. To be sure of playing correctly, it is necessary to generate a Basic Strategy table for the specific rules of the game being played. Various tools are available online to do this. We would recommend this Blackjack Basic Strategy Calculator.

It should be noted that even playing perfect Basic Strategy for the rule set in play, the player will still usually be at a disadvantage.

Card Counting

Card Counting provides the player a mathematically provable opportunity to gain an advantage over the house. It must be understood that this does not guarantee that the player will win. Just as a regular player may win though good luck despite playing at a disadvantage, it is perfectly possible for the Card Counter to lose through an extended period of bad luck even though playing with a small advantage over the House.

The basic premise of Card Counting is that mathematically speaking, low cards on average are beneficial to the dealer while high cards favour the player. There are many subtle reasons for this but the most significant are:

  • A player who receives a Blackjack (a ten value card and an Ace – two high cards) is paid one and a half times their bet. The dealer however only receives the player’s bet when dealt a Blackjack.
  • While the player can stop taking additional cards at any time, rules require the dealer to continue drawing cards until they reach a total of 17. The player can choose whether or not to take an additional card on a total of 16 whereas the dealer has to take one. In this situation small cards are less likely to cause the dealer to bust are thus favour the dealer, while big cards cause the dealer to bust more often and favour the player.
  • The majority of situations where it is correct of the player to double are starting hands that would be made very strong by the addition of a ten value card or an Ace. Therefore, doubling becomes more favourable when there are more ten value cards and Aces left in the deck.

So the Card Counter looks for times when there are more high cards left to be played than a regular deck would have. Rather than trying to remember each card that has been played, the Card Counter will usually use a ratio system that offsets cards that are good for the player against cards that are good for the dealer.

The most commonly used Card Counting system is the HiLo count, which values cards as follows:

High cards: 10, J, Q, K, A: -1
Medium cards: 7, 8, 9:0
Low cards: 2, 3, 4, 5, 6:+1

To keep track the player starts at zero, adds one to the total every time a low card is played and subtracts one from the total when a high card is played. This is called the ‘Running Count’. It may seem counter-intuitive to subtract one for high value cards that are good for the player, but a high card that has been played is one less high card that is left to be played. Where the Running Count is positive the player knows that there are more player favourable cards remaining to be played.

When kept correctly the Running Count will start at 0 and, if all the cards were to be played out, would end at 0. This is because there are an equal number of high cards and low cards. The HiLo count is therefore referred to as a ‘Balanced Counting System’.

Card Counting systems are generally not impeded by the addition of multiple decks to the game. At any rate multiple decks do not make it significantly more difficult for the Card Counter to keep track of the Running Count, since the Card Counter only needs to keep track of a single number, the Running Count. However many decks are used, the count begins at zero and would end at zero if there were no cards left, so no changes need to be made to the counting process.

Where multiple decks do make a difference is in how much impact a positive Running Count has to the player advantage. If the Running Count is +10 and there are two decks remaining to play, this means there are an extra 5 player favourable cards in each deck. If there are 5 decks remaining to be played there are only 2 extra player favourable cards in each deck. The higher the concentration of extra player favourable cards the stronger the player’s advantage. To estimate the strength of the player advantage the Running count therefore needs to be divided by the number of decks remaining to be played. This figure is called the True Count.

With the True Count the player has a consistent measure of how many extra player favourable cards are contained within the cards remaining to be dealt. The player can use this information to vary their bet and playing strategy. Deviations from Basic Strategy are far less important than placing big bets when the True Count is high and low bets (or preferably nothing) when the True count is low or negative.

It is important to note that sizing your bet correctly is critical to your long term success as a card counter. This requires substantial additional knowledge that is beyond the scope of this article. Instead we refer interested readers to the books listed below for an insight into this complex aspect of card counting.

While Card Counting is legal in most jurisdictions, for obvious reasons casinos do not like players that can consistently beat them. They therefore employ counter measures and any players they identify as Card Counters will be asked to leave the casino. The most common method used to identify Card Counters is to watch for a large bet spread (difference between the minimum and maximum bet a player uses) and to see whether large bets correlate with player favourable counts. Card Counters have developed several methods to help them avoid detection. The two most common are:

  • Wonging / Back Counting. Named after Blackjack author Stanford Wong, this is the practice of watching the cards being played and only sitting down to play when there is a player favourable count. This practice reduces the bet spread the player uses as they only place bets in player favourable situations but casinos are now well aware of this strategy and watch out for players hanging around a table and not playing. The method is still useful, but not without its problems.
  • Team Play. This involves several trained Card Counters working together. Most commonly there would be several 'Spotters' sitting at different tables keeping track of the count and either back counting or playing minimum bets. When a table reaches a positive count the Spotter would signal to the 'Big Player' who would come over and bet big during the player favourable count. This allows both players to make very little variation in their bets. Casinos are aware of this strategy and watch for groups of players working together.

There are several variations on team play designed to be employed in different situations and to different effects. These are covered more fully in the reading resources detailed below.

Successful Card Counting is generally only profitable in land based casinos, not in online games. The strategy relies on the game having a 'memory' in that cards are dealt from the cards remaining after previous rounds have been played. Online Blackjack games are dealt by computer and normally use a random number generator to shuffle the whole deck after every round of play. Games of this sort are not countable.

There are some Live Blackjack games online, which are played over a video feed with a human dealer. These could technically be counted but there are several significant disadvantages that make this difficult or not worth the player's time:

  1. Games of this type are very slow to play. A slow game means less money made.
  2. The games generally offer poor 'penetration'. This means that the decks are shuffled early, not allowing enough cards to be dealt out for many player favourable situations to develop. (The most favourable situations for the player tend to occur further into the shoe.)
  3. The casino's software records every player bet and all the cards dealt. This makes it relatively easy for a casino to employ software to track the count and watch for players raising their bet or only playing when the count is favourable.
What

For the above reasons Card Counting has not become commonplace online.

Recommended Books

There is a great deal more to card counting successfully than we can reasonable cover here. Many books have been written on this subject and we will recommend some of the better ones below:

Donald Schlesinger: Blackjack Attack – One of the foremost mathematicians in the Blackjack field, Schlesinger successfully compares the strength of various counting systems in different conditions.

Arnold Snyder: Blackbelt in Blackjack – One of the most easily accessible authors on the subject of Blackjack, Snyder still provides everything you need to know to start on your journey.

Rick Blaine: Blackjack Blueprint – A good book covering everything from Basic Strategy, through several counting systems and on to advanced techniques and team play.

Bryce Carlson: Blackjack for Blood – Discussion of various card counting systems and strategies to avoid being detected. Includes discussion of some strategies that unlike card counting, may not be legal. As such we would strongly advise user caution and research before engaging some of the strategies discussed.

Ian Andersen: Burning the Tables in Las Vegas – One of the best discussions of how to play successfully long term without being detected.

Olaf Vancura and Ken Fuchs: Knockout Blackjack – Credited as being the first published unbalanced counting system (system that did not require a True Count conversion).

Ken Uston: Million Dollar Blackjack – An old book now but written by a man famous for popularising the concepts of team play. This book covers several counting systems alongside some advanced techniques.

Kevin Blackwood: Play Blackjack Like the Pros – This book covers Basic Strategy, a variety of counting systems, money management and team play.

Stanford Wong: Professional Blackjack – One of the definitive books on the topic, the act of waiting for a favourable deck before sitting down to play is to this day referred to as ‘Wonging’.

Nathaniel Tilton: The Blackjack Life – A autobiographical account of a small number of players implementing modernised team play strategies. Very useful insight into how team play can still be effective.

Eliot Jacobson: The Blackjack Zone – A lot of space is devoted to how to become a better player and debunking myths surrounding gambling, but this book also has a good treatment of the basics of card counting.

Peter Griffin: The Theory of Blackjack – Peter Griffin was one of the most widely respected gambling mathematicians of all time. This book is maths heavy but very informative.

There are other good books on this subject but the above are the ones we feel any player should ensure they are familiar with before considering trying to win money by Card Counting.

Sites for blackjack rules, information and analysis

Here are some other useful websites with rules and information about Blackjack (21).

ThePogg.com provides a Blackjack Guide with rules, advice and casino reviews. The Basic Strategy section includes a comprehensive calculator that can generate the optimal basic strategy for almost any rule combination alongside a fairness calculator to check your results.

BlackjackInfo.com was formerly run by Kenneth R Smith but has now been acquired by an affiliate advertisement network. The forums on this site still contain a wealth of information and discussion on the various aspects of card counting.

Blackjack in Color is an unusual free Web-based Blackjack book providing an analysis of Blackjack and Card Counting illustrated by 139 charts. The author Norm Wattenberger also publishes the Blackjack Scams site, which points out some short-cuts that will more likely cost you money than make a profit, runs Blackjack The Forum and publishes Casino Verite Blackjack Card Counting training software..

Wizard of Odds has a large Blackjack section with information on the game, its variants and strategy. They provide a trainer with which you can practice card counting.

James Yates has written a page Blackjack Solved, which explains Harvey Dubner's Blackjack card counting system.

The Wikipedia Blackjack page needs little explanation. A well detailed and referenced information source on Blackjack.

Welcome, Dear Readers, to the latest edition of my long-running Modeling Practice series!

The newest game for this series is now available on my sister site BlazorGames.net, and it's a casino favorite: Blackjack!

Blackjack has been a staple of casinos and other gambling parlors since at least 1768, and it remains one of the most popular games today. This is at least partly due to the fact that it is easy to play, can have a considerable amount of strategy, and may even be more winnable than other casino-style games.

Let's model Blackjack as a C# and Blazor WebAssembly program! In the process, we'll discuss how to model complicated real-world scenarios such as this one, what kinds of decisions we need to make, and what sort of compromises we might encounter when trying to make the real world into a computer program.

Rules of Blackjack

If you already know how to play Blackjack, skip to the 'Modeling the Game' section below.

Blackjack is a casino-style card game in which the player(s) attempt to beat a dealer's score while getting as close to 21 points as possible, without going over. It is played with a standard four-suit, 52-card deck. Players do not compete against each other.

In order to know how to model a real-world problem as a program, we need to know the rules and boundaries of the problem. Lucky for us, Blackjack has a well-defined set of rules and regulations, and it all starts with betting.

Betting

Each player makes a bet before the initial deal. The bet can be any amount up to the amount of money they brought with them to the Blackjack table. This bet is lost if the player loses the hand.

The Initial Deal

After bets are made, the dealer then deals two cards to each player (this is called the initial deal) where each card is worth a certain number of points:

  • 2-9 cards are worth the amount shown.
  • Ten, Jack, Queen, and King cards are worth 10 points, and are collectively referred to as 'ten-cards'.
  • Aces are worth either 1 or 11 points, at the player's discretion.

The dealer also receives two cards, the first face-down and the second face-up.

Hit, Stand, and Bust

After each player has two cards, each player may choose to either stand or hit. If the player stands, the dealer will not deal them any more cards; the score they have is now their final score for this hand.

If the player chooses to hit, the dealer deals them another card face-up. The player can keep hitting until they decide to stand or they bust, meaning their cards have a value of more than 21. If the player busts, they lose their bet.

Dealer Behavior

The dealer's turn occurs after all players have had their turns. On the dealer's turn, they flip over their face-down card, and then either hit or stand based on the score of their cards.

The dealer will always behave in the same manner. They must hit on all scores of 16 or less, and stand on all scores of 17 or more.

Naturals AKA Blackjack

A 'natural', AKA a 'blackjack', is an Ace and a ten-card. If a player is dealt a blackjack, it is an automatic win for the player (unless the dealer also has a blackjack) and they receive one-and-a-half times the amount of their bet. So, if the player has bet $20 and is dealt a blackjack, they get their $20 bet back, plus $30 in winnings.

Payouts

How To Deal Blackjack 21

After the dealer has had their turn, the dealer will pay out any players that won their hands, and collect the bets of the players that lost their hands. The payouts and collections are calculated according to these rules:

  1. As mentioned above, if the player has a blackjack and the dealer does not, the player receives one-and-a-half times their bet.
  2. If the dealer has a blackjack and the player does not, the player has gone bust, or the dealer's score is higher than the player's score, the player loses their bet.
  3. If the dealer has gone bust, or the player has a higher score, the player wins their bet (so a bet of $20 returns the bet and gets an additional $20).
  4. If the dealer and the player have the same score, no money changes hands. This is referred to as a push.

After the payouts and collections are complete, a new hand can begin.

Special Plays

In addition to the 'normal' gameplay of Blackjack, there are a few special plays the player can make in certain situations.

Double Down

If the player, after the initial deal, has 9, 10, or 11 points showing in their hand, they can choose to 'double down'. This doubles their original bet, and the player receives one additional card. After this, the player is forced to stand.

If the player wins the hand, they get their doubled bet back, plus the doubled bet again. In other words, if the original bet was $20 and the player chooses to double down, their bet increases to $40. If the player wins the hand, they get the $40 bet back, plus an additional $40.

The dealer does not have the option to double down.

Insurance

If the dealer's face-up card is an Ace after the initial deal, the player may choose to make an insurance bet. This bet is up to half the amount of the original bet, and is placed separately of it.

If the player makes an insurance bet, the dealer looks at the face-down card. If it is a ten-card (meaning the dealer has a blackjack), the dealer flips it over, pays the player twice the insurance bet, and (if the player does not also have a blackjack), collects the player's original bet. In this way, the player is 'protected' from the dealer having a blackjack.

To model this, say the original bet was $20 and the dealer is showing an ace. The player can bet up to $10 as an insurance bet. If the dealer has a blackjack, the player 'loses' their $20 bet but gains $20 from the insurance bet. In effect, the player loses no money.

However, if the dealer does not have a blackjack when the player makes an insurance bet, the player immediately loses the insurance bet amount, and play continues normally.

Modeling the Game

Before we can begin creating the C# classes and Blazor components necessary to model Blackjack, we must think about the different parts of the game that we need to model.

There are two ways to do this: top-down, and bottom-up. In the top-down method, we would look at the game as a whole and divide it into pieces, which would then be divided into more pieces, until we couldn't make a meaningful division anymore. This method is useful for situations in which you do not already understand or know about each piece.

This entire series will use the bottom-up method. In this method, we look for objects that do not have any dependencies, model them, and them model the classes that rely on them, so on up the chain until we have modeled each object.

Assumptions

Prior to modeling this game in earnest, we must discuss any assumptions that we are making in order to have an implementable and not-too-complex model.

First, we will assume that we only need to model a single player and a dealer. Since the players do not compete against each other, modeling multiple players would model the real-world more accurately, but make the implementation much more complex.

Second, we will assume that our game will only use a single deck of cards, and will reshuffle that deck when needed. In the real world, casinos use many decks of cards shuffled together to prevent card counting, but since this is not the real world, we will conveniently ignore that fact.

With the assumptions made, we can continue with our bottom-up modeling method. In Blackjack, the smallest object with no dependencies is the playing card, so we will start by modeling the cards and the deck they're drawn from.

Cards and the Deck

We must consider the kinds of attributes each playing card will have in order to model them.

Individual cards will each have a suit (e.g. Clubs, Diamonds, etc.) and a value (e.g. Queen, Jack, Six, etc.). For the purposes of Blackjack, the suit doesn't actually matter, but we will include it because looking at a playing card with no suit makes very little sense. Given that there are a known and limited number of suits and values, we will make both the suit and the value into enumerations.

Per the rules of Blackjack, each card has a score. This is different from the value because of ten-cards; a card's value may be a Queen, but its score is still ten points.

In short, the card object will need:

  • A suit
  • A value
  • A score

Now let us consider the deck, which we will treat as a fully separate object and not just a collection.

The deck will need an underlying collection of some kind that keeps all the cards currently in the deck; this could be an array or something more complex. The deck will also need to be able to instantiate itself (i.e. create all the cards it needs and add them to the deck) and shuffle itself.

The dealer will need to interact with the deck, primarily to draw cards from it; we will need a method for that. Since the deck must be able to create and store the cards on instantiation, we'll need a method to add cards to the deck as well.

Therefore, the card deck will need:

  • The ability to create all the necessary cards and add them to the deck.
  • The ability to shuffle.
  • Methods to add cards to and draw cards from the deck.

Dealer and Player Commonalities

One of the ways in which I ask programmers to better understand the problem they are trying to model is to consider two objects and find their commonalities, the things they both need to do.

In this spirit, let's consider the player and the dealer. In many ways, they are the same; they each need a set of cards for their hand, they each need to know and show their score, and they each need to know if they are busted.

So, there will be a common object that both player and dealer can inherit from. We'll call that object Person, and it will need the following abilities:

  • Keep a hand of cards
  • Use the hand to calculate a score
  • Use the hand to determine if they are busted

True Score vs Visible Score

There is one thing that might trip us up here: the dealer's true score (i.e. the combined score of all their cards) and their visible score (the combined score of all face-up cards) are different, and the player can only know about the latter. The true score is a commonality, but the visible score is not. We'll need to deal with that in some way.

Dealer Object

We already know that the Dealer object will inherit from the Person object we discussed in the last section. The dealer will need some attributes that are unique to him/her, including:

  • The ability to deal cards to themselves and any player.
  • The ability to flip over their face-down cards.

We now need to consider the special play called Insurance. In that play, they player can make a special bet if and only if the dealer is showing an Ace face-up. So, the dealer needs one additional property:

  • Check if they have an Ace showing face-up.

The game area (which we will discuss later) can check that property to see if the player is allowed to use the Insurance play.

How To Play 21 Dealer

Player Object

What Are The Dealer Rules For Blackjack

The player, like the dealer, will inherit from the Person object and gain their attributes. They will also have certain attributes unique to them, and first and foremost among these is funds.

Funds

Our simulation will assume that each player sits at the Blackjack table with a limited amount of 'starter' funds. These funds allow the player to make bets, and are added to or subtracted from when the player wins or loses.

Blackjack Rules Dealer Has 21

Bets

Each player has a bet that is unique to him/her that they make at the start of each hand. The player object must track these bets, as well as the special Insurance bet.

Change Amount

In our simulation, a 'bet' is money that has not yet left the Player's funds. It is instead being 'risked'. So our player will need to track how their funds will change after the current hand, based on whether they win, lose, or push. We will call this the change amount.

At the end of each hand, the player object uses the change amount to determine what their new funds amount is.

Standing

Players have the option to 'stand', which means they stop drawing more cards. We'll need a property to identify if a player has decided to stand, because at that point it becomes the dealer's turn.

Summary

In short, the player object must store:

  • Their bets, including Insurance and Double Down bets.
  • Their remaining funds.
  • The change amount, the amount by which the player's funds will change after the current hand is complete.
  • Whether or not the player has stood.

The Game Area

In a real-world game of blackjack, blackjack is played at a specialized table. Here, the dealer is in charge of everything, including whether or not players can use one of the special plays.

In our implementation, we don't want to make the Dealer object in charge of notifying the Player about whether or not they can make a special play, because doing so would require a kind of messaging system between the two objects, and that is too complex for this sort of modeling.

Instead, we will introduce a Game Area object that manages situations such as these. The Game Area will need to know

  • What the player's and dealer's scores are.
  • What part of the game is currently happening (betting, dealing, hit/stand, etc.).
  • What special plays are currently available to the player, if any.

Because getting a Blackjack is a big deal in this game, we will want to output a special message to the display when a Blackjack occurs. Therefore the Game Area will want to know:

  • Whether the player or the dealer (or both) has a Blackjack.

Game Status

In Blackjack, certain things can only happen at certain times. For example, if a player has stood, they are not allowed to hit again on the same hand.

To keep track of the game and what state it is currently in, we will need an enumeration of the possible states. As we code up the C# model, we will determine what game states are needed and define them as members of this enumeration.

How to deal blackjack 21

What I'm Leaving Out: Splitting

In a real-world game of blackjack, if the player is dealt two cards with the same value (e.g. two sixes, two eights, two Aces, etc.) they can choose to 'split' the hand and copy their original bet for the second hand. The two hands are then treated independently, and a player can hit or stand or use special plays on each of them. Payouts are also dealt with separately.

I am leaving this out because modeling this tended to break my design in ways I couldn't resolve nicely. I'm still working on how to model this efficiently and in a way that I can explain simply, which doesn't involve duplicating all the affected attributes and properties or making a collection of collections. If I do get to that point, there will be another blog post about it.

Summary

The model for our Blazor implementation of Blackjack is complete, and here are the objects we need to code:

  • Card, including suits and values
  • CardDeck
  • Person
  • Dealer
  • Player
  • The game status
  • The game area

The objects for the last two items are not clearly defined yet. As we build our C# model, we will determine how best to implement those two objects.

How To Beat The Dealer At Blackjack 21

Did I miss something? Is there a better way of modeling Blackjack in C# and Blazor? Or can you make my implementation better? I want to know about all these things! Sound off in the comments below.

In the next part of this series, we will code up the C# model for Blackjack, including each of the objects above and how they interact. Card counters, get ready for some action!

Blackjack Rules Dealer Has 21

Happy Coding!