{"id":21813034,"url":"https://github.com/llamasoft/martin_solve","last_synced_at":"2025-07-14T20:36:25.368Z","repository":{"id":8833426,"uuid":"10536081","full_name":"llamasoft/martin_solve","owner":"llamasoft","description":"A Martingale betting strategy \"solver\". (PHP)","archived":false,"fork":false,"pushed_at":"2013-06-07T21:50:05.000Z","size":101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T09:23:40.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/llamasoft.png","metadata":{"files":{"readme":"README.md","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":"2013-06-06T20:42:19.000Z","updated_at":"2013-12-16T15:52:54.000Z","dependencies_parsed_at":"2022-09-19T08:11:04.036Z","dependency_job_id":null,"html_url":"https://github.com/llamasoft/martin_solve","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/llamasoft/martin_solve","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llamasoft%2Fmartin_solve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llamasoft%2Fmartin_solve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llamasoft%2Fmartin_solve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llamasoft%2Fmartin_solve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llamasoft","download_url":"https://codeload.github.com/llamasoft/martin_solve/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llamasoft%2Fmartin_solve/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265344870,"owners_count":23750570,"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-27T14:26:47.120Z","updated_at":"2025-07-14T20:36:25.092Z","avatar_url":"https://github.com/llamasoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Martingale Solver\n==================\n\nThis is a rudimentary Martingale betting method \"solver\".\nGiven an initial bet amount and a target bankroll, the script will provide the bet multiplicand required to reach the target round number.\n\n\nUsage\n------\n\nThe script accepts four parameters: the starting bet, available bankroll, the minimum number of rounds, the maximum number of rounds.\n\n    php martin_solve.php INITIAL_BET BANKROLL MIN_ROUNDS MAX_ROUNDS [FEE]\n\n\nExample\n-------\n\nSay you're placing a $1 bet and have a $100 bankroll.\nYou want to know what to multiply your bet by to survive anywhere from 2 to 10 rounds:\n\n    php martin_solve.php 1 100 2 10\n\n    Start: 1\n    Bank:  100\n    Min R: 2\n    Max R: 10\n    \n      Rounds   Incr w/ Fees     Min Reward      Final Bet\n    ========================================================\n           2       99.00000        1.01020       99.00000\n           3        9.46243        1.11817       89.53756\n           4        4.24877        1.30781       76.69916\n           5        2.84110        1.54316       65.15429\n           6        2.23439        1.81011       55.69264\n           7        1.90692        2.10263       48.08397\n           8        1.70536        2.41772       41.94760\n           9        1.57019        2.75380       36.95027\n          10        1.47394        3.10999       32.83298\n\n\nThe results indicate that in order to survive to exactly round 6, we'd need to multiply our bet by ~2.234 after each loss.  If we lose the 6th round, we're out 100% of our bankroll.\nAlso worth noting is the Minimum Reward column.  If the game's payout is _less than_ the minimum reward, making profit on a win is no longer guaranteed.\nFor example, lets assume you're playing a 50/50 game with a payout of exactly 2 but use the multiplicand specified for 10 rounds.  If you win on round 10, you'll be left with _less_ than your initial bankroll.\n\n\nNotes\n-----\n\nThe algorithm used to determine the correct multiplicand is based on the [sum of a geometric series](https://en.wikipedia.org/wiki/Geometric_series#Sum).\nThat is to say, ```BANKROLL = BET * (1 - INCREMENT^ROUNDS)/(1 - INCREMENT)```.\nSince it's non-trivial to isolate INCREMENT and solve for it, the script uses a binary search to hone in on the correct solution.\n\n\nBoring Stuff\n------------\n\nThe script also has two values that can be tweaked.\n* ```FEE``` (argument) - A flat rate fee per bet.  This is useful for some applications (bitcoin betting).\n* ```ITER``` (internal) - Number of binary search iterations when solving the geometric sum.\n\nThis script will not solve instances where the bet increment is less than 1.  It just doesn't make sense.\nNo matter what this program suggests, there will always be a possibility of losing your entire bankroll.  That's how gambling works.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllamasoft%2Fmartin_solve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllamasoft%2Fmartin_solve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllamasoft%2Fmartin_solve/lists"}