← Back to Projects

Gambling Guns

Playable demo
How it works ↓
Scroll for how it was made

Play money only: nothing here costs or pays real money. Press space to spin, and click or press space to skip animations.

01The project

A slot machine, built from the math up

Type
Personal learning project
Stack
C# / .NET 9 · Haxe / OpenFL
Genre
Cluster pays, 6×5, tumbles
Status
Playable prototype

Gambling Guns is a complete slot-machine prototype I built to learn every layer of slot development: the math, the server, the client, the animations and the features. It's a 6×5 cluster-pays game with tumbling reels and a weapon theme, and you can play it above with play money.

The goal was never to make a casino game, but to understand how one really works under the hood: how a few hundred symbols on a reel strip decide what a game pays back, how to price a bonus buy honestly, and why the server, never the browser, has to decide every outcome.

02By the numbers

Verified by simulation

94.27%Base game RTPReturn to player over 2M spins
94.28%Bonus buy RTPAt a derived price of 100× the bet
27.3%Hit frequencyShare of spins that win something
1 in 362Bonus triggerFree spins make up 27% of the RTP
7.0×VolatilityStandard deviation per spin, in bets
2,824×Largest win seenVia bonus buy; 1,794× in the base game

Measured with the project's own Monte Carlo simulator: 2,000,000 base-game spins and 100,000 bonus buys on a fixed seed.

03Symbols

Paytable

Wins are multiples of the total bet, by cluster size. The frame colour shows a symbol's tier, so value can be read at a glance.

Symbol 581215+
AK-47 High5.14×23.94×196×1137×
Desert Eagle High3.49×15.77×125×696×
Sawed-Off Mid2.51×10.91×84.86×455×
Nova Mid1.89×8.19×62.14×325×
R8 Revolver Low1.45×6.13×46.23×235×
Five-SeveN Low1.13×4.77×35.62×179×
P250 Low0.91×3.79×28.04×140×
Glock Low0.76×3.18×22.73×113×
Wild Golden crateSubstitutes for every paying symbol and can join several clusters at once.
Scatter Clover4 / 5 / 6 / 7+ anywhere pay 2× / 5× / 25× / 100× and award 10 / 15 / 20 / 25 free spins.

How it plays

  • Cluster pays: 5 or more matching symbols touching horizontally or vertically win anywhere on the 6×5 grid. There are no paylines.
  • Tumbles: winning symbols pop, everything above falls down, new symbols drop in, and the grid is evaluated again until no clusters remain.
  • Scatters: 4 or more clovers trigger free spins. Clovers never pop, so they keep counting through the whole tumble chain.
  • Persistent multiplier: during free spins, every winning tumble raises the multiplier by one, and it never resets until the bonus ends.
  • Bonus buy: pay 100× the bet for a spin that is guaranteed to trigger the bonus, priced so it pays back the same as normal play.

Pricing the bonus buy

The hardest problem in the project was a single number. A fair bonus buy price is the bonus's average value divided by the base game's RTP, so it has to be derived by simulation, never guessed. Every change to the game moved it:

  1. 100×The first guess. Simulation showed the bonus was only worth about 26× the bet, which made the button a 26% RTP purchase.
  2. 27–28×Derived instead of guessed, then re-derived when the symbol set shrank from 10 to 8.
  3. 42×Scatters started counting across the whole tumble chain, so free spins retriggered far more often.
  4. 107×The multiplier became persistent and the buy got a guaranteed trigger spin. The bonus went from ~40× to ~100× in value.
  5. 100×A new, continuous lever that scales free-spin wins (to 91.3%) let the price land on an exact round number: 94.28% RTP for the buy against 94.27% for normal play.

How it's built

The project is layered so the game type can change without touching the random number generator or the RTP tools. That paid off when the game went from paylines to clusters: the simulator kept working unchanged.

ClientHaxe · OpenFL

Renders and animates. Sends a bet, plays back the result.

APIASP.NET Core

Owns the balance and validates every bet against a whitelist.

MathC# library

Reel strips, clusters, tumbles, free spins and a cryptographic RNG.

SimulatorMonte Carlo

Plays millions of seeded rounds to measure RTP, volatility and prices.

The client is a video player: it sends a bet and receives the entire round, every tumble, cluster and grid, already decided. That is non-negotiable in real-money games, because anything running in the browser can be modified.

About this web version: GitHub Pages can't run a server, so the build on this page runs a Haxe port of the C# math directly in the browser. That's only acceptable because it's play money. The port was verified against 3,300 rounds recorded from the C# engine together with every random number they used: replayed through the port, every grid, cluster and payout matched exactly.

What I learned

  • Find the number that really drives RTP. Almost every win is a minimum-size cluster, so the two lowest paytable columns controlled nearly all of the RTP. Tuning the big wins barely mattered.
  • Move one lever at a time. Changing two things at once tells you nothing about which one did what.
  • Hit rate and RTP are separate levers. The structure of the reel strips decides how often the game pays; the paytable decides how much.
  • A price is a ratio. Scaling the whole paytable can't change a bonus buy's fair price. Only levers that move the bonus relative to the base game can.
  • Fair randomness has details. A cryptographic RNG for play, a seeded one for reproducible simulations, and rejection sampling so no reel position is ever favoured.
  • Presentation is its own craft. Gravity animations, scatter teasers, skipping and a win display that never covers what the player is watching all change how fair and exciting the same math feels.

A note on AI

For efficiency, I used AI to speed up the development process. Every technical part, from the reel math and RTP tuning to the server and the client, was still built with a full understanding of how and why it works. To me, AI is a tool that makes me faster, not a replacement for knowing how to build things.

A prototype, not a product

Gambling Guns is a learning project. It has no real money, player accounts, database, spin history, responsible-gambling tools or certification, all of which a real game would legally need. Nothing on this page can be bought or won.