No description
  • JavaScript 75.6%
  • HTML 13%
  • CSS 11.4%
Find a file
Jimmy Berglund 44b4f9023a
Comet Cash: retune bought-bonus volatility; persistents-on-land toggle
Bought bonuses were all-or-nothing: almost half landed nothing, and a
persistent black hole plus persistent comet grew with the square of the
bonus length, so 1,000x+ rounds carried ~46% of the return (median 21x on
a 100x buy).

- New bonus.persistOnLand rule (Lab toggle): persistent specials act
  again only on respins where something lands. On for Comet Cash, Sands
  of Gold, Thunder Vault and Sugar Stack; off (act every respin) for
  Dragon Hoard and Abyss Treasure, the volatile versions.
- Default rates: more orbs and one-shot comets/black holes (they add,
  filling the middle), fewer doubling specials and persistents (they
  multiply, making the tail). Orb values weighted toward x2-x5.
- Reskin overrides rewritten to keep each one's character, orb rates
  solved to keep average bonus values; super buy prices repriced to ~94%.
- Recalibrated bonus tables; shape test replaces the old persistent-rate
  test; persistOnLand test added; README and write-up numbers updated.

Medians now 25-52x, 14-22% of buys pay back, tail 10-36% of the return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 15:50:22 +01:00
css Lobby: hero carousel, painted key-art tiles, mascots, sticky categories 2026-11-06 23:23:38 +01:00
js Comet Cash: retune bought-bonus volatility; persistents-on-land toggle 2026-11-07 15:50:22 +01:00
scripts Keep every bought bonus and bonus choice in the house's favour; honest ante; super-buy wilds 2026-11-02 15:22:13 +01:00
test Comet Cash: retune bought-bonus volatility; persistents-on-land toggle 2026-11-07 15:50:22 +01:00
.gitignore Add Comet Cash hold-and-win game, shared casino shell and landscape layout 2026-11-01 17:29:31 +01:00
anywhere.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00
book.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00
classic.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00
cluster.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00
comet.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00
folly.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00
how-it-works.html Comet Cash: retune bought-bonus volatility; persistents-on-land toggle 2026-11-07 15:50:22 +01:00
index.html Lobby: hero carousel, painted key-art tiles, mascots, sticky categories 2026-11-06 23:23:38 +01:00
package.json Add Fortune's Folly: a play-money slot machine that exposes its tricks 2026-11-01 15:40:25 +01:00
README.md Comet Cash: retune bought-bonus volatility; persistents-on-land toggle 2026-11-07 15:50:22 +01:00
sticky.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00
ways.html Fix stage layering and fitting: mascots, value labels, first paint, board size 2026-11-06 23:11:08 +01:00

Folly Casino

A realistic online-style casino played with play money: a lobby and eight original slot games that look and feel like real online slots. Every page has a Lab that lets you switch off each deceptive design trick and see the real math behind the machine.

Running it

No build step and no dependencies. ES modules need to be served over HTTP:

npm start            # python3 -m http.server 8000
# open http://localhost:8000 (the lobby)

Any static host (e.g. GitHub Pages) works.

npm test             # engine tests (Node 20+)

What's in it

A lobby (index.html) with thirty "games" that are really reskins of eight games, all with a landscape layout like modern online slots: the grid in the middle, round side panels (free spins, respins, totals, jackpot plaques, bonus buy) and a slim control bar. Each has a ? button in the top bar explaining how it works, its symbols, and what makes it different.

Fortune's Folly: a 5×3, 20-line video slot with wilds, scatters and 10 free spins at ×3. It has synthesised background music that changes with the game (base game, free spins, big-win fanfare), reel and coin sounds, staggered reel stops with bounce, chasing cabinet lights, symbol shimmer, animated paylines that cycle line by line, coins flying into the balance, escalating BIG → MEGA → EPIC win screens with a coin fountain, autoplay, a paytable and a cash-out screen that hands you play-money bills. You can play in SEK, NOK, DKK, EUR, GBP, USD or a generic ¤; the default follows the browser's language. A fullscreen button (or the F key) fills the screen; hide the Lab for a machine-only view.

Each game has its own stage (js/shared/stage.js, css/stage.css, css/themes/<game>.css, js/<game>/theme.js): a living scene behind the reels, its own symbol art, a themed frame, and an original mascot who reacts to the game. Fortune's Folly is Las Vegas neon with Dicey the top-hatted die; Firecracker 7s a lantern festival with Ember the dragon; Grimoire of Gold a candle-lit library with Sable the cat; Cherry Bell 7s a 1950s lounge with the Cherry Twins; Sweet Cascade a candy land with Gummo the jelly bear; Rune Rush a Norse fjord under the aurora with Skald the raven; Comet Cash a retro-futurist alien horizon with Rivet the robot; Nebula Gems deep space with Nova the star-owl. All of it is SVG, CSS and canvas, no image files. The Lab's Presentation switches turn the mascot, the win effects and the idle animation off one by one.

The Lab (right-hand panel):

Tab What it does
Tricks Toggles and sliders for each technique, with presets: Typical online casino, UK rules (2021), Swedish rules, Honest machine
Math RTP slider, exact RTP breakdown, simulated hit/LDW/near-miss rates, a chart of the virtual reel's stop weights, and the odds the paytable never prints
Truth For the last spin: the raw RNG numbers, how long the decision took versus the animation, and whether that "win" was really a loss. Plus session stats and history
Simulator Sends 1,000+ virtual players to the current machine, then shows where they finished and how their balances moved

Tricks you can switch: near-miss weighting, unbalanced reels, celebrating losses disguised as wins, slow win count-ups, cheap BIG WIN thresholds, bonus anticipation teasers, visible off-screen symbols, credits instead of money, sound design, spin speed, slam stop, autoplay, a fake jackpot ticker, fake "someone just won" pop-ups, deposit-bonus pressure, the bonus-buy sales pitch, and (in Nebula Gems) a cheering mascot, win sparkles with shattering gems, and a living scene with idle animation. Protective features: a session time & net-result bar, reality-check pop-ups, a daily deposit limit, and the Swedish responsibility bar (Spelpaus / Spelgränser / Självtest), and the Swedish limits-and-result message at login. Every switch does one thing.

The write-up: how-it-works.html, How online casinos really work, in six parts: the machine (RNGs, virtual reels, RTP), presentation tricks, a tour of slot types, the casino around the games, protection and the law, and help. It covers RNGs, virtual reels, RTP, volatility and each design technique, UK and Swedish regulation (Spellagen, Spelförordningen, LIFS 2018:2), research references and links to help resources.

The games: a range of slot types

Real slots are not one design. Each family of games has its own mechanics, and each mechanic has its own ways of making losing feel like winning. Folly Casino has one original game per family. They share one wallet, one Lab, one Truth tab, one simulator and one set of player protections, so the tricks can be compared side by side. Every game is original; none is a copy of a commercial title.

# Type How it works What it is here to show Status
1 Payline video slot (Fortune's Folly) 5×3 reels, 20 fixed lines, wilds, scatters, free spins. Its math profile (js/folly/profile.js) adds 5×4 boards with 40 lines, stacked or expanding wilds and retriggering free spins; the reskins use them, and the maths stays exact Virtual reels, near misses, losses disguised as wins, bonus teasers; generous-looking wild features paid for with smaller pays Done
2 Hold-and-win respins + bonus buy (Comet Cash) No reels: 20 cells that each spin on their own, paying on 1,024 ways. Orbs carry multipliers of the bet (×0.5 … ×100) and lock in place; each new symbol resets the respin counter to 3. A dozen specials collect, pay, double, snipe, revive, convert and upgrade, with persistent versions that act every respin. The bonus board grows from 5 to 7 columns when a column fills or a rift lands; a full board pays a grand prize. The bonus can be bought for around 100× the bet. Each reskin has its own math profile (board size, specials, rates), and the Math tab's Advanced mode exposes every knob The respin reset as a near miss that keeps repeating; buying the bonus has about the same RTP as normal play, but money goes 100 times faster; persistent specials make most of the biggest wins but show up in only ~1 bonus in 8 (median buy ~35× on a 100× price; about 4 buys in 5 lose); jackpot labels (MINI / MAJOR / GRAND) on prizes that are just multiples of the bet Done
3 Cluster pays with tumbles (Sweet Cascade, cluster.html) 7×7 grid; groups of 5+ touching symbols pay, explode and tumble. Exploded cells become multiplier spots (×2 … ×128). Bonus: free spins where the spots never reset; also buyable, plus a super buy that starts every cell as a ×2 spot. Profiles add colour bombs, cluster wilds, other grid and cluster sizes (Gummy Galaxy, Jelly Jackpot Rush) One spin turns into a chain of small "wins" that often add up to less than the bet; multipliers that look huge on tiny amounts. RTP calibrated by simulation (scripts/calibrate-cluster.mjs) Done
4 Variable ways (Rune Rush, ways.html) 6 reels of 2–7 symbols, so the ways change every spin (up to 117,649); ways pays with cascades. Bonus: choose your free spins (16×1, 11×11 or 5×40) with a multiplier that grows on every cascade; a super buy starts at ×5. Profiles add a horizontal top reel, mystery symbols and reels up to 8 high (Temple of Ways, Nordic Fortunes) A big ways number used as marketing; constant tiny hits; an illusion of choice (all bonus options average the same). RTP calibrated by simulation (scripts/calibrate-ways.mjs) Done
5 Pay anywhere with multipliers (Nebula Gems, anywhere.html) 6×5 grid; 8+ of a symbol anywhere pay, with tumbles. Multiplier orbs (×2 … ×500) multiply a winning sequence; without a win they're wasted. Bonus: free spins with a running total multiplier that grows on winning spins; a super buy with only big orbs. Profiles add an ante bet that shows its measured bonus boost (Starfall Treasures) and other grid sizes (Crown of Orbs) Big multipliers on small wins; orbs celebrated on spins that win nothing. RTP calibrated by simulation (scripts/calibrate-anywhere.mjs) Done
6 Multiplier wilds + sticky free spins (Firecracker 7s, sticky.html) 5×3, 20 lines; wilds on reels 2–4 carry ×2/×3 and multiply together on a line. Bonus: free spins on their own reels where every wild sticks (or, in Dragonfire Wilds, walks one reel left each spin); a super buy starts with two wilds in place Wilds celebrated on lines that don't win; a bonus whose average (~97×) is carried by rare huge rounds (median ~36×). Base game exact; bonus value simulated (scripts/calibrate-sticky.mjs) Done
7 Book slot with an expanding symbol (Grimoire of Gold, book.html) 5×3, 10 lines; a book that is wild (reels 2–5) and scatter. Bonus: 10 free spins with a randomly chosen special symbol that expands to fill its reels and pays on all lines; retriggers. Versions with two expanding symbols, or one more per retrigger; a bonus buy, plus "pick your symbol" buys priced from each symbol's average The special-symbol "ceremony" stages a random draw as a big moment and hides how unequal the symbols are (Wizard ~259×, King ~34×); long dry spells, with ~46% of the return in the bonus. Base game exact; bonus value per symbol simulated (scripts/calibrate-book.mjs) Done
8 Classic 3-reel (Cherry Bell 7s, classic.html) One line, 22-stop reels with blanks, BARs, 7s, cherries, 1–3 coins. Profile options: 3 or 5 lines and wild-multiplier 7s (Gold Bar Classic, Retro Reels) The original virtual reel (fair reels would pay >100%; virtual makes the jackpot ~25× rarer), near misses mapped next to the jackpot, and "buy-a-pay" coins. All maths exact (10,648 combinations) Done
9 Casino lobby (index.html) The entry page: 30 "games" that are reskins of #1–#8 with different names, colours, symbol sets (cards, gems & treasure, runes) and RTPs (85–96%) Clones and hidden RTP versions; "Featured" = lowest RTP; fake HOT badges, player counts and recent-win tags; a free-spins funnel. A Lab switch reveals each tile's engine and RTP Done

Other families worth knowing about, not planned for now: the gamble feature (double-or-nothing on red/black after a win), ways to win (243 / 1024 ways, a simpler version of #4), and progressive jackpots shared across machines or players.

How RTP is handled per game

The payline slot's RTP is calculated exactly from its reel strips. Comet Cash goes further: every number its maths depends on lives in a math profile (js/comet/profile.js). Each lobby version overrides part of it (math in js/catalog.js), and the Math tab's Advanced mode lets the player change any of it. With Hold RTP on, the solver re-tilts the hidden weights (and, if a bigger board makes that impossible, scales the base pays) to keep the target; with it off, the RTP is whatever the settings produce. A changed bonus has no calibrated table, so it is re-estimated live in Web Workers. Like RTP experiments, these changes last until the page is reloaded. js/shared/math-profile.js holds the engine-agnostic parts (profile merging, the advanced panel); js/shared/math-lab.js mounts the Basic/Advanced switch on any game's Math tab, and js/shared/estimate-pool.js runs live estimates in a small pool of workers.

Tiered bonus buys. Games with a buy offer a normal and a super tier (Comet Cash: the bonus starts with a persistent special, at about 3× the price). The Math tab compares their RTP, median and share of losing buys: the pricier tier is a bigger bet, not a better deal. For cascades and respin bonuses no practical exact formula exists, so those parts are measured with large simulations, and the Lab says so (e.g. "measured over 2M spins, ±0.3%"). Where a game mixes both (a base game with exact math plus a simulated bonus), each part is labelled.

How the math works

js/engine.js holds the real model:

  • Each reel is a physical strip of symbols (js/config.js). Every stop has a hidden weight, and the RNG (crypto.getRandomValues) picks stops in proportion to those weights.
  • Exact RTP is computed from the strips and weights, the same way a manufacturer's PAR sheet is. Reels are independent, so every line combination's probability is a product of per-reel marginals. Scatter counts are convolved across reels, and free spins are added as P(trigger) × spins × multiplier × base RTP.
  • To hit a target RTP, a solver tilts the weights toward or away from valuable windows, using a binary search.
  • Near-miss weighting multiplies the weight of stops that leave a premium or scatter just off-screen. The solver then re-balances, so near misses rise but the RTP doesn't move.
  • Tests check that the exact RTP matches a Monte Carlo run, that the solver hits its targets, and that near-miss weighting raises the near-miss rate at the same RTP.

Layout

index.html               the casino lobby (30 tiles, 8 engines)
sticky.html              Firecracker 7s (multiplier wilds, sticky-wild free spins)
js/sticky/               its engine (exact base game), bonus value, app, symbols, worker
book.html                Grimoire of Gold (book slot, expanding symbol)
js/book/                 its engine (exact base game), bonus value per special symbol, app, symbols, worker
anywhere.html            Nebula Gems (pay anywhere, multiplier orbs, running-multiplier bonus)
js/anywhere/             its engine, calibration table, app, symbols, worker
ways.html                Rune Rush (variable ways, cascades, choose-your-free-spins)
js/ways/                 its engine, calibration table, variable-height reels, app, symbols, worker
cluster.html             Sweet Cascade (cluster pays, tumbles, multiplier spots)
js/cluster/              its engine, calibration table, grid renderer, app, symbols, worker
classic.html             Cherry Bell 7s (classic 3-reel, 1 line)
js/classic/              its engine (exact), app, symbols, worker
folly.html               Fortune's Folly (payline slot); ?v=<id> opens a reskin
js/lobby.js              lobby tiles, fake activity, promo, reveal
js/catalog.js            the 12 versions: names, colours, symbol set, default RTP
js/symbol-sets.js        alternative symbol art (gems & treasure, runes) that versions can swap in
comet.html               Comet Cash (hold & win + bonus buy); ?v=<id> opens a reskin
how-it-works.html        the write-up
css/style.css
js/config.js             Fortune's Folly: symbols, paytable, paylines, strips; currencies
js/engine.js             Fortune's Folly math: RNG, weights, exact RTP, solver, simulation
js/app.js                Fortune's Folly game module
js/comet/config.js       Comet Cash: symbols, ways pays, strips, orb values
js/comet/profile.js      Comet Cash math profile: defaults, specials, board layout, the Advanced schema
js/comet/engine.js       Comet Cash math: exact ways RTP + trigger odds, bonus simulation, solver
js/comet/bonus-ev.js     calibrated bonus values per version (generated)
js/comet/app.js          Comet Cash game module (base game, hold & win, bonus buy, Lab panels)
js/comet/symbols.js      Comet Cash symbol art
js/shared/casino.js      shared shell: wallet, session, Lab switches & presets, protections,
                         Swedish bar, deposits, reality checks, simulator, fullscreen
js/shared/math-profile.js  math profiles: merging, overrides, the Math tab's advanced panel
js/shared/bigwin.js      BIG → MEGA → EPIC win screen
js/shared/ui.js          modals, toasts, coin and number animations
js/shared/format.js      currency formatting
js/reels.js              reel rendering & animation (Fortune's Folly)
js/cells.js              per-cell spinning grid (Comet Cash base game and bonus)
js/audio.js              Web Audio music and sound effects
js/symbols.js            Fortune's Folly symbol art
js/settings.js           Lab switches, presets, explanations
js/charts.js             canvas charts for the Lab
js/sim-worker.js, js/comet/sim-worker.js   simulations in Web Workers
scripts/calibrate-comet.mjs                regenerates js/comet/bonus-ev.js (every Comet Cash version)
scripts/tune-comet.mjs                     finds the orb rate that gives a version's bonus a target average
test/                    engine tests for both games

If you change Comet Cash's bonus rules, orb values, profile defaults or a version's math, run node scripts/calibrate-comet.mjs (about 3 minutes on 8 cores); node scripts/tune-comet.mjs <version> 95 helps pick a version's orb rate first. If you change Sweet Cascade's pays, weights, bonus or a version's math, run node scripts/calibrate-cluster.mjs (it keeps tables that are still current; --all redoes them), for Rune Rush node scripts/calibrate-ways.mjs (same options), and for Nebula Gems node scripts/calibrate-anywhere.mjs (each about 2 minutes on 8 cores); for Firecracker 7s node scripts/calibrate-sticky.mjs (about a minute; covers every version and its super buy); for Grimoire of Gold node scripts/calibrate-book.mjs (about 30 seconds; every version). Tests fail if any table is out of date.

Disclaimer

Educational project. Play money only: nothing can be bought, won or withdrawn. The game and its numbers are original and illustrative, not a copy of any commercial slot. If gambling is a problem for you or someone close to you: BeGambleAware (UK, 0808 8020 133), 1-800-GAMBLER (US), or gamblingtherapy.org (worldwide).