{"uid":"cap_X4LWrgVSh5d8Wq2HiJbRz","slug":"gambler-s-ruin-calculator-edb9012d","name":"Gambler's Ruin Calculator","description":"Gambler's ruin: probability of going broke before hitting a target, and expected number of bets, for repeated unit bets.","url":"https://probability-calc.x402tookit.com/gamblers-ruin?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["p","bankroll"],"properties":{"p":{"type":"number","description":"Probability of winning each bet, 0 to 1 (roulette red/black on a double-zero wheel 18/38 = 0.473684)"},"target":{"type":"integer","description":"Stop when you reach this many units (omit to play until ruin)"},"bankroll":{"type":"integer","description":"Starting units, 1 to 1000000"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"asOf":{"type":["null","string"]},"source":{"type":["null","string"]},"target":{"type":["null","number"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"bankroll":{"type":["null","number"]},"degraded":{"type":["boolean","null"]},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"ratioQOverP":{"type":["null","number"]},"expectedBets":{"type":["null","number"]},"winProbability":{"type":["null","number"]},"lossProbability":{"type":["null","number"]},"ruinProbability":{"type":["null","number"]},"successProbability":{"type":["null","number"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_mDvSCMyoA_JLdgaCLnN2d","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Calculates the probability of going broke before reaching a target bankroll, and the expected number of bets, for repeated unit-bet gambling scenarios.","exampleAgentPrompt":"I'm playing roulette betting on red each spin — that's an 18/38 win probability. I'm starting with 100 chips and want to quit if I reach 200. What's my probability of going broke first and how many bets should I expect before the game ends?","exampleUseCases":[{"title":"Roulette session ruin analysis","prompt":"I'm heading to the casino with $150 and want to play roulette on red/black — win probability is about 0.4737 on a double-zero wheel. What's my chance of losing everything before I hit $300, and how many spins should I expect?"},{"title":"Biased coin gambling edge check","prompt":"I have a coin with a 52% chance of heads. Starting with 200 units and trying to reach 400, what's my ruin probability and expected number of flips before I either bust or hit my target?"},{"title":"Infinite play ruin probability","prompt":"If I start with 500 units and bet one unit at a time with a 48% win chance, and I have no target — I just play until I go broke — what's the probability of eventual ruin and roughly how many bets will it take?"}],"resultDescription":"Returns the probability of ruin (going broke), probability of success (hitting the target), win probability, loss probability, ratio q/p, and expected number of bets before the game ends. Also includes a summary, verdict, and disclaimer. If no target is provided, models play until ruin.","failureModes":["Missing required parameter 'p' or 'bankroll' returns an error","Win probability 'p' outside 0–1 range is invalid","Bankroll outside 1–1,000,000 range is rejected","Target lower than or equal to bankroll may produce undefined or trivial results","Floating-point precision issues for very large bankrolls or near-zero edge scenarios"],"whenToPreferThis":"Choose this endpoint when you need mathematically exact gambler's ruin probabilities and expected bet counts for unit-bet repeated-trial scenarios with a fixed win probability. Ideal for analyzing casino game strategies, bankroll management, or any symmetric/asymmetric random walk problem with absorbing barriers. Prefer this over generic probability distributions when you specifically need the two-barrier ruin/success model.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T13:08:19.142Z","isFirstParty":false,"canonicalSlug":"gambler-s-ruin-calculator-edb9012d"}