Text-based BlackJack
This is a simple text-based blackjack written fully in C++. Most of the key features of Blackjack are fulfilled.
To compile and run the program,
-
Linux/Mac OS
make ./bj
-
Windows
Compile and run using any IDE.
Screenshot,
- A much simpler version can be found here
- A seperate branch is created in an attempt to analyze how the factors affect the winning probabilities, along with what is right thing to do for the players. I'm also considering to get the max winning probability (rate) a player can reach, given that there's only one deck of cards and the player is capabale of memorizing all the used cards.
Key Features
Load Game Settings (Dealer's Perspective)
- Choose how many decks are used in a game.
- Shuffle Rules. Either a shuffle is triggered every hand or it's not triggered until there're 15 or less cards left.
- Soft 17 Rule. Choose whether the deal stands when he has a soft 17.
- Split limits. The maximum number that a player can split.
All the above are stored in a file named "bjconfig.dat".
A typical
bjconfig.dat
is as follows,
DeckNum 2
SplitLimit 2
ShuffleEveryRound 0
HitSoft17 1
A screenshot how the program restricts the number of splits,
If not found, the default values will be used, which are respectively,
- Only 1 deck of cards is used.
- A shuffle is triggered only when the cards are not enough to use (15 or less).
- Dealer hits when the 17 is soft.
- The player can split no more than 3 times.
Game Rules
Player Decisions
- Hit. Take another card from the dealer
- Stand. Take no more cards.
- DoubleDown. The player is allowed to increase the initial bet by up to 100% in exchange for committing to stand after receiving exactly one more card.
-
Split (only available as the first decision of a hand). If the first two cards have the same value, the player can split them into two hands, by moving a second bet equal to the first into an area outside the betting box. The dealer separates the two cards and draws an additional card on each, placing one bet with each hand. The player then plays out the two separate hands in turn.
After a split, the player can still double on the first round, but he can no longer surrender. The number of split limits is by default 3, but can be changed in the
bjconfig.dat
file.Example of mutiple split,
Surrender (only available as first decision of a hand). After the dealer has checked for blackjack, the user can choose to surrender. By doing so, the house takes half the player's bet and returns the other half to the player.
Dealer's Decisions
- Hit. If the dealer's cards add equal to or less than 16, he must choose to hit.
- Stand. If the dealer's cards add equal to or more than 17, he must choose to stand.
Beat the Dealer
The player can beat the dealer in one of the following ways,
- Get 21 points on the player's first two cards (called a blackjack), without a dealer blackjack;
- Reach a final score higher than the dealer without exceeding 21; or let the dealer draw additional cards until his or her hand exceeds 21.
Load and Save the Game
The game offers a choice to load game and save games.