Skip to content

A small game engine for casino blackjack and a library for calculating hand probabilities.


Notifications You must be signed in to change notification settings


Folders and files

Last commit message
Last commit date

Latest commit



60 Commits

Repository files navigation


Build Status

A small game engine for blackjack, and a library for calculating hand probabilities.

The game engine is still very basic and needs a lot of functionality added. Its use is to create the needed scenarios for calculating hand probabilities. To see an example of hand probabilities being calculated please see here. There is also an example source file that can be found in the examples directory.


You can use the game engine and probability library separately or together.

var game = new Blackjack.Game('player1', 'house', {
	numberOfDecks: 1

// Start a new game;

var shoe = game.getShoe();
var dealerCards = game.getDealer().getCards();
var playerCards = game.getPlayer().getCards();			

// Calculate probabilities for standing, hitting, and doubling down
var stand = Blackjack.Probability.stand(shoe, dealerCards, playerCards, 3);
var hit = Blackjack.Probability.hit(shoe, dealerCards, playerCards, 3);
var double = Blackjack.Probability.double(shoe, dealerCards, playerCards, 3);


  • numberOfDecks {Integer}
    • The number of decks in a shoe. The standard in most casinos is between 4 and 8.
  • dealerHitSoft17 {Boolean}
    • If true the dealer will hit on soft 17, otherwise the dealer will continue to draw cards.


The following are all the public methods exposed through the Game, Player, and Probability API.


  • getDealer()
    • Returns the dealer object.
  • getPlayer()
    • Returns the player object. Only one player in a game supported right now.
  • getTurn()
    • Returns the player or dealer, depending on which turn is set.
  • setTurn(player)
    • Takes a player object and sets that player or dealer as the active turn.
  • getShoe()
    • Returns an array of all card objects in the shoe.
  • deal()
    • Handles the game setup, i.e., card shuffling, turn setting, etc.


  • getCards()
    • Returns an array of the players cards.
  • canSplit()
    • True if the player can split their cards, false otherwise.
  • canDouble()
    • True if the player can double down, false otherwise.
  • getActions()
    • Returns an array of all the actions available to the player.


The dealerCards and playerCards can be retrieved using game.getPlayer().getCards(). The maxPullCount is used to limit the number of times the recursive function is called. A number between 3 and 5 will return a reasonably accurate result while still being fast.

  • stand(shoe, dealerCards, playerCards, maxPullCount)
  • hit(shoe, dealerCards, playerCards, maxPullCount)
  • double(shoe, dealerCards, playerCards, maxPullCount)


There are many features for the game engine that need to be added and/or worked on:

  • Add splitting to the probability library
  • Handle player and dealer chip amounts
  • Support for more than one player to a game

There are many options that need to be supported in the game constructor:

  • playerResplitAces
  • player5Card21
  • playerSurrender


To build blackjack please run:


The combined minified file will appear in the dist folder.


MIT license.


A small game engine for casino blackjack and a library for calculating hand probabilities.







No releases published