{"id":21455693,"url":"https://github.com/skyl/broken-knuckles","last_synced_at":"2025-07-14T23:32:52.577Z","repository":{"id":4336629,"uuid":"5472326","full_name":"skyl/broken-knuckles","owner":"skyl","description":"BlackJack counting simulation in Python","archived":false,"fork":false,"pushed_at":"2012-09-13T21:17:58.000Z","size":176,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-16T06:56:59.140Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skyl.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-19T16:27:28.000Z","updated_at":"2024-04-16T06:56:59.140Z","dependencies_parsed_at":"2022-08-23T17:10:27.828Z","dependency_job_id":null,"html_url":"https://github.com/skyl/broken-knuckles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyl%2Fbroken-knuckles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyl%2Fbroken-knuckles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyl%2Fbroken-knuckles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyl%2Fbroken-knuckles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skyl","download_url":"https://codeload.github.com/skyl/broken-knuckles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226002995,"owners_count":17558157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-23T05:13:08.173Z","updated_at":"2024-11-23T05:13:09.117Z","avatar_url":"https://github.com/skyl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"`broken-knuckles` is a small library to evaluate different blackjack rules\nand betting strategies.\n\nDo not trust `broken knuckles`. Blackjack is a pile of special cases.\nFind the flaws in `broken knuckles` and report them. Do not gamble; gambling is bad.\nThe best card counting strategies are risky in the short term and you can go\ndown (way down) for hours and hours playing the best strategy.\nYou will probably bankrupt yourself.\n\n\nThe class, `game.Game` is the basis. You instantiate a `Game` and simulate some hands.\nThe default betting is just 1 unit per hand regardless of count. You can replace this\nbetting strategy with the `get_bet` kwarg to game. Let's simulate\na game which pays 3:2 on blackjack and a game which pays 6:5.\n\nMostly, I have just been using the ipython notebook with pylab to run simulations.\n\nYou can enter the notebook, `ipython notebook --pylab inline`.\n\n::\n\n    import pandas\n    import game\n    import betting\n    reload(betting)\n    reload(game)\n    import pylab as pl\n\n    g32 = game.Game(get_bet=betting.basic_kelly, blackjack_pays=1.5)\n    g65 = game.Game(get_bet=betting.basic_kelly, blackjack_pays=6/5.)\n\n    g32.play_shoes(10000)\n    g65.play_shoes(10000)\n\n    games = [\n        g32,\n        g65,\n    ]\n    num = min([len(i.money_trail) for i in games])\n    df = pandas.DataFrame({\n        \"3/2\": g32.money_trail[:num],\n        \"6/5\": g65.money_trail[:num],\n    })\n    df.plot(title=\"BlackJack Pays, 3/2 vs 6/5\")\n\n    g32.print_summary()\n    g65.print_summary()\n\n\nCalling plot above may give you an image like this:\n\n.. image:: https://s3.amazonaws.com/skyl/blackjackpays.png\n\nAnd, the `print_summary` calls may print some stuff out like::\n\n    final units 14302.0\n    num hands 151635\n    winnings per hand 0.0943185939922\n    min units= -1223.0\n    max units= 14760.0\n    Hours with 1 hand per minute= 2527\n    $25 units= 357550.0\n    $5 units= 71510.0\n\nCheck out `game.Game.__init__` for the options to game.\nAs of the time of writing, the above code simulates:\n\n* Infinte splits\n* can double after split\n* Only 1 card after split Aces\n* 1 deck with 75% penetration\n* perfect counting, perfect and undeviated basic strategy\n* no other players at table\n* dealer stands on soft 17\n\nThese can be changed with arguments to `Game`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyl%2Fbroken-knuckles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskyl%2Fbroken-knuckles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyl%2Fbroken-knuckles/lists"}