{"id":17869683,"url":"https://github.com/mhluska/blackjack-simulator","last_synced_at":"2026-04-24T08:01:34.866Z","repository":{"id":39924062,"uuid":"270744593","full_name":"mhluska/blackjack-simulator","owner":"mhluska","description":"🃏 Realistic blackjack simulator (practice card counting using Hi-Lo and calculate EV for any table conditions)","archived":false,"fork":false,"pushed_at":"2026-04-18T18:21:58.000Z","size":2450,"stargazers_count":66,"open_issues_count":7,"forks_count":21,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-18T20:26:23.072Z","etag":null,"topics":["blackjack","blackjack-game","blackjack-simulator","cli","javascript","multiprocessing","nodejs","simulator","typescript"],"latest_commit_sha":null,"homepage":"https://blackjacktrainer.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mhluska.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"mhluska"}},"created_at":"2020-06-08T16:38:22.000Z","updated_at":"2026-04-18T18:22:00.000Z","dependencies_parsed_at":"2023-11-17T00:12:02.561Z","dependency_job_id":"dee7663f-1b1e-4221-9444-908c8fb051dd","html_url":"https://github.com/mhluska/blackjack-simulator","commit_stats":{"total_commits":277,"total_committers":3,"mean_commits":92.33333333333333,"dds":"0.15523465703971118","last_synced_commit":"fed648b1e1dde3bf1c752a75838eca5e9d0f392c"},"previous_names":["mhluska/blackjack-engine","blackjacktrainer/blackjackjs-engine"],"tags_count":88,"template":false,"template_full_name":null,"purl":"pkg:github/mhluska/blackjack-simulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhluska%2Fblackjack-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhluska%2Fblackjack-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhluska%2Fblackjack-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhluska%2Fblackjack-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mhluska","download_url":"https://codeload.github.com/mhluska/blackjack-simulator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhluska%2Fblackjack-simulator/sbom","scorecard":{"id":242176,"data":{"date":"2025-08-11","repo":{"name":"github.com/mhluska/blackjack-simulator","commit":"a8cce86795737980a1831e071f9a7cd21fc6c721"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/20 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/mhluska/blackjack-simulator/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/mhluska/blackjack-simulator/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/mhluska/blackjack-simulator/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/mhluska/blackjack-simulator/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/mhluska/blackjack-simulator/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/mhluska/blackjack-simulator/test.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   3 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":2,"reason":"8 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T06:52:18.608Z","repository_id":39924062,"created_at":"2025-08-17T06:52:18.614Z","updated_at":"2025-08-17T06:52:18.614Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32214420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T03:15:14.334Z","status":"ssl_error","status_checked_at":"2026-04-24T03:15:11.608Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blackjack","blackjack-game","blackjack-simulator","cli","javascript","multiprocessing","nodejs","simulator","typescript"],"created_at":"2024-10-28T10:09:16.083Z","updated_at":"2026-04-24T08:01:34.833Z","avatar_url":"https://github.com/mhluska.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mhluska"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/mhluska/blackjack-simulator/raw/master/preview.gif\" alt=\"Preview\" /\u003e\n\u003c/p\u003e\n\n# Blackjack Simulator\n\n\u003ca href=\"https://github.com/mhluska/blackjack-simulator/actions\"\u003e\u003cimg src=\"https://github.com/mhluska/blackjack-simulator/actions/workflows/test.yml/badge.svg?branch=master\" alt=\"Build Status\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/@blackjacktrainer/blackjack-simulator\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@blackjacktrainer/blackjack-simulator.svg\" alt=\"Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/mhluska/blackjack-simulator/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/mhluska/blackjack-simulator\" alt=\"License\"\u003e\u003c/a\u003e\n\n\u003e Practice card counting using Hi-Lo and calculate EV for any table conditions\n\n## Features\n\n- Simulator mode for computing EV given any table conditions\n- [Game mode](https://blackjacktrainer.app) for practicing basic strategy and card counting with hints\n- No package dependencies\n- Runs in any JS environment (CLI, browser, React Native app etc)\n- Multi-core support in Node\n\n## Usage\n\n### Simulator mode\n\n```sh\nnpm install -g @blackjacktrainer/blackjack-simulator\n```\n\n```sh\nblackjack-simulator simulate --help\n```\n\nOverride the number of CPU cores used:\n\n```sh\nCORES=1 blackjack-simulator simulate\n```\n\n### Game mode\n\n```sh\nblackjack-simulator game --help\n```\n\nSee it live as a web app [here](https://blackjacktrainer.app).\n\n### Build and run locally\n\n```sh\nnpm install\nnvm use --install\nNODE_ENV=development npm run build\n./bin/cli.js\n```\n\n### Use as a library (simulator mode)\n\n```js\nimport { Simulator } from '@blackjacktrainer/blackjack-simulator';\n\n// Default settings:\nconst settings = {\n  debug: false,\n\n  // Simulator-only settings:\n  hands: 10 ** 7,\n  // Can be one of:\n  // 'basic-strategy': play perfect basic strategy\n  // 'basic-strategy-i18': play perfect basic strategy plus illustrious 18\n  // 'basic-strategy-i18-fab4': play perfect basic strategy plus illustrious 18 + fab 4\n  playerStrategy: 'basic-strategy-i18-fab4',\n\n  playerBetSpread: [1000, 1000, 4000, 7000, 10000],\n  playerSpots: [1, 1, 1, 1, 1],\n  playerTablePosition: 1,\n  playerBankroll: 1000 * 10 ** 7,\n  playerWongOutTrueCount: -Infinity,\n\n  // Table rules\n  allowDoubleAfterSplit: true,\n  allowLateSurrender: false,\n  allowResplitAces: false,\n  blackjackPayout: '3:2',\n  deckCount: 2,\n  hitSoft17: true,\n  maxHandsAllowed: 4,\n  maximumBet: 1000 * 100,\n  minimumBet: 1000,\n  playerCount: 1,\n  penetration: 0.75\n};\n\nconst simulator = new Simulator(settings);\nconst result = simulator.run();\n```\n\nResult contains the following data:\n\n```\n{\n  amountEarned: number;\n  amountWagered: number;\n  bankrollMean: number;\n  bankrollVariance: number;\n  handsLost: number;\n  handsPlayed: number;\n  handsPushed: number;\n  handsWon: number;\n  hoursPlayed: number;\n  riskOfRuin: number;\n  timeElapsed: number;\n}\n```\n\n### Use as a library (game mode)\n\n```js\nimport {\n  Event,\n  Game,\n  GameStep,\n  PlayerInputReader\n} from '@blackjacktrainer/blackjack-simulator';\n\n// Default settings:\nconst settings = {\n  autoDeclineInsurance: false,\n  disableEvents: false,\n  checkDeviations: false,\n\n  // Can be one of 'default', 'pairs', 'uncommon', 'deviations'. If the mode is set to 'deviations', `checkDeviations`\n  // will be forced to true.\n  mode: 'default',\n  debug: false,\n\n  playerBankroll: 1000 * 10 ** 7,\n  playerTablePosition: 1,\n  playerStrategyOverride: {},\n\n  // Table rules\n  allowDoubleAfterSplit: true,\n  allowLateSurrender: false,\n  allowResplitAces: false,\n  blackjackPayout: '3:2',\n  deckCount: 2,\n  hitSoft17: true,\n  maxHandsAllowed: 4,\n  maximumBet: 1000 * 100,\n  minimumBet: 1000,\n  playerCount: 1,\n  penetration: 0.75\n};\n\nconst game = new Game(settings);\n\n// In a real app, this will likely be a React-redux store or a Vuex store.\nconst state = {};\n\n// Called when any game state changes. `name` will be one of the following:\n//\n// - focusedHand\n// - sessionMovesCorrect\n// - sessionMovesTotal\n// - playCorrection\n// - step\n// - shoe\n// - discardTray\n// - dealer\n// - player\n// - handWinner\ngame.on(Event.Change, (name, value) =\u003e {\n  state[name] = value;\n});\n\ngame.on(Event.Shuffle, () =\u003e {\n  console.log('End of shoe, cards shuffled!');\n});\n\n// Emitted when the game wants to save optional game statistics.\n// `entityName` can be one of `hand-result` or `move`.\n// `data` is a plain object with values to save to the backend.\ngame.on(Event.CreateRecord, (entityName, data) =\u003e {\n  fetch(`/api/v1/${entityName}`, {\n    method: 'POST',\n    body: JSON.stringify(data),\n    headers: {\n      Accept: 'application/json',\n      'Content-Type': 'application/json'\n    }\n  });\n});\n\nfunction stepGame(game, playerInputReader, input) {\n  const step = game.step(input);\n\n  if (\n    ![\n      GameStep.WaitingForPlayInput,\n      GameStep.WaitingForInsuranceInput,\n      GameStep.WaitingForNewGameInput\n    ].includes(step)\n  ) {\n    return Promise.resolve();\n  }\n\n  return new Promise((resolve) =\u003e playerInputReader.readInput(resolve));\n}\n\nasync function runGame(game) {\n  game.betAmount = 10 * 100;\n\n  const playerInputReader = new PlayerInputReader();\n  let input;\n\n  while (true) {\n    input = await stepGame(game, playerInputReader, input);\n  }\n}\n\nrunGame(game);\n```\n\n`PlayerInputReader.readInput` listens for a `click` or `keypress`\nevent on `document.body`. Your DOM just has to declare the following buttons\nsomewhere for user interaction:\n\n```jsx\n{\n  game.state.step === GameStep.WaitingForPlayInput \u0026\u0026 (\n    \u003c\u003e\n      \u003cbutton data-action=\"s\"\u003eStand (S)\u003c/button\u003e\n      \u003cbutton data-action=\"h\"\u003eHit (H)\u003c/button\u003e\n      \u003cbutton data-action=\"d\"\u003eDouble (D)\u003c/button\u003e\n      \u003cbutton data-action=\"r\"\u003eSurrender (R)\u003c/button\u003e\n      \u003cbutton data-action=\"p\"\u003eSplit (P)\u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n{\n  game.state.step === GameStep.WaitingForInsuranceInput \u0026\u0026 (\n    \u003c\u003e\n      \u003cbutton data-action=\"n\"\u003eNo (N)\u003c/button\u003e\n      \u003cbutton data-action=\"y\"\u003eYes (Y)\u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n{\n  game.state.step === GameStep.WaitingForNewGameInput \u0026\u0026 (\n    \u003c\u003e\n      \u003cbutton data-action=\"d\"\u003eDeal (press any key)\u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n## Performance\n\nTested on Apple M2 Max, Node v24.3, default settings (2-deck H17, I18 + Fab 4 deviations, bet spread).\n\n| Cores | Hands | Time | Hands/sec |\n|---|---|---|---|\n| 1 | 100M | ~53s | ~1.9M |\n| 4 | 1B | ~134s | ~7.5M |\n| 12 | 1B | ~65s | ~15M |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhluska%2Fblackjack-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmhluska%2Fblackjack-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhluska%2Fblackjack-simulator/lists"}