Code Monkey home page Code Monkey logo

blackjack's Introduction

BlackJack Card Counting

This repository does show an implementation for calculating the expected value in a game of black jack based on perfect play. Therefore the card distribution, handcards of the player and the dealer's face card are taken into account for accurate calculation of the expected value on each game decision. A min-max Strategy is used to traverse a probabilty tree and find optimal decisions based on the given parameters.

Through counting the dealt cards and observing the distribution of still available cards a player can minimize the dealers advantage and maybe even tilt it in his favor.

Python Prototype

The prototype of the calculation is written in python and does implement a recursive depth first search probability tree traversal. Hands and available card distributions are represented by a class. To avoid double calculation of different shoe-hand combinations a lru-cache system is implemented for the functions.

C++ Implementation

The fast c++ implementation does follow the same recursive calculation scheme like the protottype. For faster calculation better memory handling and more efficient data structures are used. The calculation does still traverse the whole propability tree by a recursive scheme and no simplifications are made in the card distribution. This does allow more exact decision making especially on small shoes and less available cards The faster c++ Implementation does not support caching yet. Additionally a thread based load balancer system could make the calculation much faster but is also still not implemented.

Game-Settings

Setting Default Meaning
HIT_ON_SOFT_17 false if true dealer will hit on soft 17 hands.
DOUBLE_AFTER_SPLIT false if true layer is allowed to play double down on splitted cards
SPLIT_AFTER_SPLIT false if true multiple splits are allowed.
BJ_PROOF_IMMEDIATELY_ON_ACE true if true the dealer checks for a black jack when an ace is shown
HIT_ON_SPLIT_ACES false if true the player is allowed to hit on splitted aces
DECKS 1 How many cards are inside the shoe
BlackJackPayout 1.5 The multiple for the payout if the player gets a blackjack
CALCSPLIT true If the option of splits should be calculated in general.

Timing

The prototype and implementation do both support time measurement for evaluating the calculation. Although the implementation has no caching, it is still up to 15 times faster than the computation of the prototype. Complex computations like dealer shows 2 and Player shows 2,2 do need quite amount of time on large decks because of the tree complexity.

The software should only demonstrate on how to perform probabilty calculation in the game of blackjack correctly without simplifications. More efficient computations do apply simplifications like a constant distribution while calculating card combination probabilities.

Disclaimer

This software should bot be used to play against casinos for two reasons.

  1. The calculation does need too much time for proper a proper game integration
  2. No warranty for the correctness of the calculation and according recommandation
  3. The casion always wins

blackjack's People

Contributors

schubert-tom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.