Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/StakeEngine/math-sdk/llms.txt

Use this file to discover all available pages before exploring further.

The Stake Engine Math SDK is a comprehensive framework for building, simulating, and optimizing slot game math. It generates all backend files, lookup tables, and simulation results required to publish a game on Stake Engine — the Remote Gaming Server (RGS) powering Stake.com.

Quick Start

Run your first game simulation in minutes using a provided sample game.

Installation

Set up Python, virtual environment, and optional Rust for optimization.

Core Concepts

Understand the game format, file structure, and simulation lifecycle.

API Reference

Full reference for all public classes and functions in the SDK.

What the SDK does

The Math SDK handles the complete backend pipeline for a slot game:
1

Define your game

Configure game rules, reelstrips, paytable, and bet modes in game_config.py using the GameConfig class.
2

Simulate outcomes

Run create_books() to execute thousands (or millions) of game simulations across multiple CPU threads, producing compressed event books and lookup tables.
3

Optimize win distribution

Run the Rust-powered optimization algorithm to balance your game to a target RTP, adjusting simulation weights to meet payout and hit-rate requirements.
4

Generate config files

Call generate_configs() to produce the frontend, backend, and math configuration files required for publishing to Stake Engine.

Key features

Four win types

Built-in support for Lines, Ways, Cluster, and Scatter pay calculations with multiplier strategies.

Multi-threaded simulation

Distribute simulations across multiple CPU threads for fast generation of large result sets.

Rust optimization

Iterative weighted sampling algorithm implemented in Rust for high-performance RTP balancing.

Event-driven architecture

All game outcomes are expressed as ordered event sequences, consumed directly by the RGS play/ API.

Sample games

Five complete example games covering Lines, Ways, Cluster, Scatter, and Expanding Wilds mechanics.

PAR sheet generation

Automatic hit-rate and RTP analysis with Excel export for regulatory and design review.

Project structure

The SDK separates reusable engine logic (in src/) from game-specific implementations (in games/<game_id>/):
math-sdk/
├── src/                    # Shared engine modules
│   ├── calculations/       # Win type implementations (lines, ways, cluster, scatter)
│   ├── config/             # Base Config class
│   ├── events/             # Event emission functions
│   ├── state/              # GameState, Executables, Conditions
│   └── wins/               # WalletManager, multiplier strategies
├── games/                  # Game implementations
│   └── <game_id>/
│       ├── game_config.py  # GameConfig (extends Config)
│       ├── gamestate.py    # GameState with run_spin()
│       ├── run.py          # Simulation entry point
│       └── library/        # Generated output files
├── optimization_program/   # Rust optimization binary
└── utils/                  # Analysis and utility scripts
Games uploaded to Stake Engine must consist of static pre-computed files. The Math SDK generates all required files — books, lookup tables, and config — in the correct format for the RGS.

Build docs developers (and LLMs) love