Giter Site home page Giter Site logo

blackjackd's Introduction

blackJackd

Blackjack simulator in Javascript.

try it

Work in progress.. but functional. Please let me know if you see any ways to make it even faster!

Supports pretty much everything (except re-splitting and insurance):

  • dealer stands on any 17 (hard or soft)
  • multi-player
  • players use basic strategy
  • player splitting
  • player blackjack pays 3 to 2
  • dealer blackjack wins (unless a player also has blackjack then they push)
  • double doubling down doubles the winnings
  • Results show (after about 1 million rounds) a house advantage of .5 percent, so it's accurate

To use, open the blackJackd_vX.html file in Chrome, input the game values, and view results in console.



Alternatively, you can use Node instead of running in the browser, both are equally fast.

To use with Node, update these variables in the blackJackd_vX.js file.

const DEBUG = false; // will output a whole bunch of stuff if true

const numPlayers = 1; // use as many as you want
const numRounds = 1000000; //100000000;
const numDecks = 8;
const outputInterval = 100000; // how often to show results snapshot

Then run it and sit back and wait

node blackJackd_vX.js

The results show:

[ win, loss, tie ]  win percentage
node blackJackd_v2.js

[ 0, 1, 0 ] 0
[ 51785, 53694, 8453 ] 49.09508053735815
[ 104079.5, 106828, 16854 ] 49.34841103327288
[ 156301, 159995, 25317 ] 49.416053317145966
[ 208501, 213133, 33912 ] 49.4507084343293
[ 260481.5, 266413, 42442 ] 49.43712640765846
[ 312732.5, 319571, 51024 ] 49.45923911539316
[ 365097.5, 372571, 59597 ] 49.493437770489045
[ 417079.5, 425984, 67901 ] 49.47189624506339
[ 469282, 479211, 76408 ] 49.47659076029027
testGameLoop: 59498.218ms
WINS ----- 521530.5
LOSS ----- 532501
TIES ----- 84784

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.