The room from the homepage, with the phone on the desk.
05 · Percival · Discord bot
My friends bet on each other’s games.
Percival is a Discord bot I built. It sets the odds with real math, takes bets in fake money, and pays out when the match ends.
1/9
Percival#the-loungePercival · prop bets on us, priced by math
Recreation. Percival’s real board runs in a private server, so this channel is rebuilt for this page: the same embed shapes and colours bot.py writes, with stand-in gamertags (LanternJaw77, QuietFox09, NorthPaw21) and illustrative kill averages (λ). No real stats or handles appear (private/roster.json).
Oneboard.Pricedtoeachplayer.
L
LanternJaw77Today at 8:04 PM
/LanternJaw77 used /session_create
🎯 Prop Board
Session: S-104 Host: LanternJaw77
👤 LanternJaw77
🔴P02 Kills — over 8.5 — 3.03
👤 NorthPaw21
🔴P09 Kills — over 4.5 — 2.71
a 'hard' bet is hard for everyone: a better player has to score more kills (eliminations in the match) to win the same bet · made-up numbers, real format
Poissonpricesit.
P
PercivalBOTToday at 8:06 PM
/Percival used /pick
Place Bet
Session: S-104 Player: LanternJaw77 Pick a prop:
Props
🟡 Kills — over 6.5 — 1.90×
PMF, P(X = k)CDF, P(X ≤ k)
λ 6.5
← drag →
Drag λ, the player’s average kills per match: the bars, the line and the price all redraw from the same three functions board.py uses (CODE 5.1). Keys: ←→ step λ.
Poisson is an 1837 formula for how often something happens. Here it sets the number you bet over or under, and what a win pays (the math is in the details below)
Notwoplayersgetthesameboard.
L
LanternJaw77Today at 8:04 PM
🎯 Prop Board
Session: S-104
👤 LanternJaw77
🟢P03 Kills — over 5.5 — 1.35 🟣TF1 Top frag — 63.7% — 2.50
defpoisson_pmf(k: int, lam: float) -> float:
if k < 0:
return0.0return math.exp(-lam) * (lam ** k) / math.factorial(k)
defpoisson_cdf(k: int, lam: float) -> float:
return sum(poisson_pmf(i, lam) for i in range(0, k + 1))
defpoisson_sf(k: int, lam: float) -> float:
"""P(X >= k)"""return1.0 - poisson_cdf(k - 1, lam)
CODE 5.2percival/board.py:333-340
defsample_poisson(lam: float) -> int:
L = math.exp(-lam)
k = 0
p = 1.0while p > L:
k += 1
p *= rand.random()
return k - 1
Knuth’s method: multiply random draws until the product falls below e^−λ. It is the sampler behind every draw in the demo above.
20,000 simulated lobbies, fractional credit on ties.
CODE 5.3percival/board.py:194-219
deffrag_probabilities(self, players, trials: int = 20000):
top_counts = {str(p.discord_id): 0for p in players}
bot_counts = {str(p.discord_id): 0for p in players}
ids = [str(p.discord_id) for p in players]
lams = [max(0.1, float(p.kills)) for p in players]
for _ in range(trials):
samples = [sample_poisson(l) for l in lams]
mx = max(samples)
mn = min(samples)
top_idx = [i for i, v in enumerate(samples) if v == mx]
bot_idx = [i for i, v in enumerate(samples) if v == mn]
top_share = 1.0 / len(top_idx)
bot_share = 1.0 / len(bot_idx)
for i in top_idx:
top_counts[ids[i]] += top_share
for i in bot_idx:
bot_counts[ids[i]] += bot_share
top_prob = {pid: top_counts[pid] / trials for pid in ids}
bot_prob = {pid: bot_counts[pid] / trials for pid in ids}
return top_prob, bot_prob
Top and bottom frag have no closed form across a whole lobby, so they’re simulated. The demo above runs a TypeScript port of these functions. Checked against the Python on 23 Sep 2026: for λ = 7.2, 5.4 and 3.8, all nine kills-over lines and prices match pick_kills_over_line_with_band exactly.
Counted, with the date they were counted.
lines of Python across 15 files (wc -l)
3,261as of 22 Sep 2026
lines in bot.py, the Discord layer
1,600as of 22 Sep 2026
simulated lobbies per board
20,000as of 22 Sep 2026
decimal odds clamp
1.05 – 25.0as of 22 Sep 2026
statistics libraries: the Poisson is hand-written
0as of 22 Sep 2026
What I don’t claim.
Play money only. No real money moves.
Season stats are entered by hand after each match, not scraped live. A Playwright scraper exists in the repo but was never wired into the live bot and doesn't work.
The simulation treats players as independent. Teammates in the same lobby aren’t.
No backtest here of how the prices did against real results.
The λ values on this page are illustrative. The real stats and gamertags stay private.
One bot, one engine, one database.
Python
discord.py
SurrealDB
asyncio
Private repository. The code samples above are the real thing, copied with their line numbers.
Proves Poisson models and 20,000-trial Monte Carlo simulation, written from the math rather than imported; SurrealDB (résumé → Percival).