blackjack statistical simulator
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
log
.gitignore
README.md
notes.txt
rules.config
statjack.rb

README.md

StatJack

A Ruby program that provides:

  • an interactive blackjack game
  • an automated blackjack simulator
  • a learning algorithm, making the best moves based upon previously observed hands and their outcomes
  • a statistics generator for win/loss odds for every decision at any given gamestate

StatJack requires the following gems:

  • awesomeprint
  • progressbar
  • htmlentities.

On Windows, uncomment the first line of the lib/requirements.rb file to allow for colorized console output with correct symbol encodings.


BlackJack

The object of the blackjack game is to accumulate cards with point totals as close to 21 without going over 21. Face cards (Jacks, Queens and Kings) are worth 10 points. Aces are worth 1 or 11, whichever is preferable. Other cards are represented by their number.

If player and the House tie, it is a push and no one wins. Ace and 10 (Blackjack) on the first two cards dealt is an automatic player win at 1.5 to 1, unless the house ties. A player may stand at any time.

Playing blackjack

To win you need to beat the dealer without busting. You bust when your cards total to more than 21 and you lose automatically. The winner is whoever has closest to a total of 21. You reach 21 by adding up the values of the cards.

The blackjack table seats about 6 players. Either six or eight decks of cards are used and are shuffled together by the dealer and placed in a card dispensing box called 'Shoe'.

Before receiving any cards players must place a wager. Then the players are dealt two cards face up. The dealer gets one face up, one face down. Each player in turn either stays or takes more cards to try and get closer to 21 without busting. Players who do not bust wait for the dealer's turn. When all the players are done, the dealer turns up the down card. By rule, on counts of 17 or higher the dealer must stay; on counts of 16 or lower the dealer must draw.

If you make a total of 21 with the first two cards (a 10 or a face and an Ace), you win automatically. This is called 'Blackjack'. If you have Blackjack, you will win one and one-half times your bet unless the dealer also has Blackjack, in which case it is a Push or a Tie (or a Stand-off) and you get your bet back.

The remaining players with a higher count than the dealer win an amount equal to their bet. Players with a lower count than the dealer lose their bet. If the dealer busts, all the remaining players win.

Additional bets and actions:

  • Insurance: side bet up to half the initial bet against the dealer having a natural 21 - allowed only when the dealer's showing card is an Ace. If the dealer has a 10 face down and makes a blackjack, insurance pays at 2-1 odds, but loses if the dealer does not.
  • Surrender: giving up your hand and lose only half the bet.
  • Double Down: double your initial bet following the initial two-card deal, but you can hit one card only. A good bet if the player is in a strong situation. Most casinos will allow you to double down on any two cards. Some casinos will let you double down after splitting and some will limit your doubling down to hands that total ten or eleven. However, there is one condition: When you double down, you must take one additional card and you cannot receive more than one.
  • Split: split the initial two-card hand into two and play them separately - allowed only when the two first cards are of equal value. Use each card as the start to a separate hand and place a second bet equal to the first.