GenerateRandomSearch

Gambler's Ruin Simulator

Start with a stake, win or lose one unit a round, and stop when you reach a target or run out. In a fair game the chance of reaching the target is simply your stake divided by the target — no exponentials needed. Tilt the odds even slightly against you and that probability collapses geometrically, which is the mathematical reason a small house edge is so much worse than it sounds. This is presented as probability, not as a betting strategy.

What this generator does

Runs a walk that moves up or down one unit each round until it hits zero or the target, many times over. It reports how often the target was reached against the closed-form probability, which takes a different form for a fair game than an unfair one.

How to use this tool

  1. Set a starting amount, a target and the chance of winning each round.
  2. Predict how often the target is reached.
  3. Run it, and compare with the exact probability.
  4. Drop the win chance a few points and watch the probability fall away.

Understanding the controls

Starting amount
Your stake, which must be below the target.
Target
Reaching this ends the run as a success; reaching zero ends it as ruin.
Chance of winning each round (%)
Fifty is a fair game, where the answer is just the ratio of stake to target. Anything less collapses geometrically.
How many runs
From 100 upwards, capped at 5,000 here since each run can take many rounds.
Seed
Reproduces exactly the same sequence of walks.

Common use cases

  • Showing how a small edge compounds over many rounds
  • Teaching absorbing barriers in a random walk
  • Risk-of-ruin estimates in an abstract setting
  • Comparing the fair and unfair formulas
  • Reproducing a specific sequence of walks from a seed

How this generator works

A fair game uses the ratio of stake to target; an unfair one uses the geometric form with the odds ratio raised to the stake and the target. The check requires the closed form to be right and the observed rate to sit within three standard errors of it.

Randomness and fairness

Each round's outcome is random; the ruin probability is computed in closed form. Seeded runs reproduce exactly and are therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator is used.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • Stakes are one unit per round; variable bet sizes change the answer substantially.
  • This is a probability demonstration, not betting advice, and nothing here suggests a system that works.
  • Runs are capped at 100,000 rounds each, which is far beyond any realistic walk at these bounds.
  • The walk is summarised rather than plotted step by step.
  • No walk is kept after the visit; seed the settings to repeat a season.

Privacy and your data

Every walk is simulated locally in your browser. Nothing about the run is transmitted or retained.