# Gambler's Ruin Calculator

> Gambler's Ruin Calculator is a paid API for AI agents from probability-calc.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-29).

Calculates the probability of going broke before reaching a target bankroll, and the expected number of bets, for repeated unit-bet gambling scenarios.

## Facts

- Endpoint: GET https://probability-calc.x402tookit.com/gamblers-ruin?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/gambler-s-ruin-calculator-edb9012d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_X4LWrgVSh5d8Wq2HiJbRz

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability gambler-s-ruin-calculator-edb9012d
```

Example prompt: 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?

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

Gambler's ruin: probability of going broke before hitting a target, and expected number of bets, for repeated unit bets.

## Output

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.

## Request schema (JSON Schema)

```json
{
 "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"
       ]
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/gambler-s-ruin-calculator-edb9012d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from probability-calc.x402tookit.com](https://www.zero.xyz/host/probability-calc.x402tookit.com/llms.txt)
