Recovery · 33% chance
Dynamic recovery dice bot script (Lua)
This script bets 33% for a 3.00x payout. While the session is below its best profit, it sizes each bet so that one win would recover the whole drawdown plus one base bet.
The bet is capped at 10% of the current balance. Once the cap applies, a win no longer recovers everything, and each further loss takes 10% of what is left.
The script
Lua 5.4 with DiceBot-style globals. The top level runs once to set chance and the first nextbet, then dobet() runs after every roll. Every global is described in the Lua reference.
-- Dynamic Recovery (calculated drawdown)
-- After a loss, size the next bet so that a single win recovers the whole session
-- drawdown plus one base bet of profit: bet = (drawdown + basebet) / (payout - 1).
-- Bets grow slower than a doubling martingale at high payouts, and the size is
-- capped as a fraction of balance so a bad run degrades instead of going bust.
chance = params.chance or 33
bethigh = false
basebet = params.basebet or balance / 20000
nextbet = basebet
local maxBetPct = params.maxbetpct or 0.10 -- never bet more than 10% of balance
local payout = (100 - houseedge) / chance
local peakProfit = profit
function dobet()
if profit > peakProfit then
peakProfit = profit
end
local drawdown = peakProfit - profit
if drawdown <= 0 then
nextbet = basebet
return
end
local target = (drawdown + basebet) / (payout - 1)
local cap = balance * maxBetPct
if target > cap then
target = cap
end
if target < basebet then
target = basebet
end
nextbet = target
end
How it works
chance = params.chance or 33withbethigh = falsewins on a roll below 33.basebetisparams.basebetorbalance / 20000, which is 0.005% of the starting balance.maxBetPctisparams.maxbetpctor 0.10.payout = (100 - houseedge) / chanceis worked out once at the start: 3.00x at a 1% house edge.peakProfitstarts atprofit(0). Indobet(), a new high inprofitraisespeakProfit, anddrawdownispeakProfit - profit.- With no drawdown the next bet is
basebet. - Otherwise the target is
(drawdown + basebet) / (payout - 1). A win on that bet paystarget * (payout - 1), which is the drawdown plus one base bet. The target is then limited tobalance * maxBetPctat most andbasebetat least.
Risk at a glance
Settings: 33% chance, 1% house edge, starting balance 0.02 (the template default, BTC in the simulator), base bet 0.000001 (balance / 20000).
The calculator assumes a fixed growth factor and a bust when the next bet exceeds the balance. This script's bet grows about 1.5 times per loss at 3.00x, then switches to 10% of the balance, so it loses a share of the balance each time instead of busting on one bet. A single win also does not always reset it, because drawdown is measured from the best profit of the session. The table follows the script's rule from a fresh start.
| Losses in a row | Chance of the streak | Result from a fresh start |
|---|---|---|
| 10 | 1 in 55 (1.82%) | Lost 0.00007589 (0.4%), next bet 0.00003844 |
| 15 | 1 in 406 (0.246%) | Lost 0.00058286 (2.9%), next bet 0.00029193 |
| 20 | 1 in 3,010 (0.033%) | Lost 0.00443268 (22.2%), next bet 0.00155673 |
| 25 | 1 in 22,291 (0.0045%) | Lost 0.01080765 (54.0%), next bet 0.00091923 |
| 30 | 1 in 165,103 (0.00061%) | Lost 0.01457201 (72.9%), next bet 0.0005428 |
Theoretical figures for a fresh start, not a simulation. The chance of N losses in a row is qN with q = 1 - chance / 100, the same formula the dice calculator uses. None of this changes the expected result: at a 1% house edge the average loss is 1% of the total wagered, whatever the progression.
Tuning it
Each setting below is read as params.name or default, so the script runs with the default until something passes a value in.
| Param | Default | What changing it does |
|---|---|---|
| params.chance | 33 | Win chance. It also sets payout, and with it how fast the bet grows: at a payout of M the uncapped bet grows about M / (M - 1) times per loss, so 1.5 times at 3.00x. |
| params.basebet | balance / 20000 | Bet when the session is at its best profit, and the profit each recovery aims for. |
| params.maxbetpct | 0.10 | Largest bet as a fraction of the current balance. A lower cap applies sooner in a losing run and slows the loss after that; a higher cap lets more runs recover fully and makes the losses bigger when they don't. |
FAQ
How is this different from martingale?
Both raise the bet after a loss. Martingale doubles each time. This script works the bet out from the drawdown, which at 3.00x grows it about 1.5 times per loss, and it caps the bet at 10% of the balance.
What happens when the cap kicks in?
From then on the bet is 10% of the current balance, so a win recovers only part of the drawdown and each further loss takes 10% of what is left. With the defaults on a 0.02 balance the cap applies after 20 losses in a row. After 30 losses in a row about 73% of the balance is gone.
Why measure drawdown from peak profit?
So the script keeps betting to recover until the session is back at a new high. After a full recovery the profit is one base bet above the old peak, the drawdown is 0, and the bet returns to basebet. A win that only covers part of the drawdown leaves the script still in recovery.
Can I run this script in DiceBot or another Lua dice bot?
The script uses the global names from Seuntjie's DiceBot (chance, bethigh, nextbet, previousbet, win, dobet()). The params table only exists in DiceSim, so replace each params.name or value with the value before you paste it into another bot. It also reads houseedge, so check that your bot provides it. DiceSim itself never places bets on a casino.
Other scripts
Martingale
Doubles the bet after each loss and goes back to the base bet after a win.
- Chance
- 49.5%
- Type
- Martingale
Delayed escalation
Bets 3.35% for a 29.55x payout. Flat bets through 50 losses, then 4% more per loss.
- Chance
- 3.35%
- Type
- Dynamic scaling
Paroli 3-step
Doubles after a win, banks the profit after 3 wins in a row, resets on any loss.
- Chance
- 49.5%
- Type
- Paroli
D'Alembert
Adds one unit after a loss and removes one after a win, never going below the base bet.
- Chance
- 49.5%
- Type
- D'Alembert
Labouchere
Bets the first plus the last number of a list. Wins cross numbers off, losses add one.
- Chance
- 49.5%
- Type
- Labouchere
Fibonacci
Bets follow the Fibonacci sequence: one step up after a loss, two steps back after a win.
- Chance
- 49.5%
- Type
- Fibonacci
Oscar's Grind
Plays in cycles that aim for +1 unit: same bet after a loss, one unit more after a win.
- Chance
- 49.5%
- Type
- Oscar's Grind
1-3-2-6
Bets 1, 3, 2 and 6 units on consecutive wins. Any loss, or the 4th win, resets to 1.
- Chance
- 49.5%
- Type
- Positive progression
Flat betting
Same bet on every roll, with a stop loss and a take profit at 10% of the starting balance.
- Chance
- 49.5%
- Type
- Flat betting
Martingale + vault
Martingale that moves half of every 1% profit step to the vault with vault().
- Chance
- 49.5%
- Type
- Martingale