# Stake Engine Math SDK ## Docs - [Introduction](https://mintlify.wiki/StakeEngine/math-sdk/introduction.md): The Stake Engine Math SDK is a Python-based engine for defining slot game rules, simulating outcomes, and generating all backend files required by the Stake Engine RGS. - [Quick start](https://mintlify.wiki/StakeEngine/math-sdk/quickstart.md): Run the sample lines game and inspect real output from the Stake Engine Math SDK in under five minutes. - [Installation](https://mintlify.wiki/StakeEngine/math-sdk/installation.md): System requirements and setup instructions for the Stake Engine Math SDK. - [Game Format](https://mintlify.wiki/StakeEngine/math-sdk/concepts/game-format.md): What the Stake Engine game format requires: static pre-computed simulation files, books in JSONL format, and lookup tables in CSV format. - [Game Structure](https://mintlify.wiki/StakeEngine/math-sdk/concepts/game-structure.md): The recommended directory layout for a Stake Engine game, what each file does, and how game-specific code relates to the shared engine source. - [Simulation Lifecycle](https://mintlify.wiki/StakeEngine/math-sdk/concepts/simulation-lifecycle.md): How a single simulation runs from RNG seeding through event emission, the repeat loop, and final output to books and lookup tables. - [Game Configuration](https://mintlify.wiki/StakeEngine/math-sdk/guides/configuration.md): Set up your GameConfig class with paytables, reelstrips, special symbols, and bet modes to define all game parameters in one place. - [Implementing GameState](https://mintlify.wiki/StakeEngine/math-sdk/guides/gamestate.md): Learn how to implement the run_spin() and run_freespin() methods that form the entry point for all Stake Engine simulations. - [Game Events](https://mintlify.wiki/StakeEngine/math-sdk/guides/events.md): Understand how to construct and emit game events — the JSON objects returned by the RGS play/ API that drive all frontend display. - [Win Types](https://mintlify.wiki/StakeEngine/math-sdk/guides/win-types.md): Reference for the four built-in win evaluation methods — Lines, Ways, Cluster, and Scatter — including wild substitution, multiplier strategies, and the win_data structure. - [Bet Modes & Distributions](https://mintlify.wiki/StakeEngine/math-sdk/guides/bet-modes.md): Configure BetMode and Distribution classes to control cost, RTP targets, max win limits, and per-simulation win criteria for each game mode. - [Sample games overview](https://mintlify.wiki/StakeEngine/math-sdk/examples/overview.md): Five complete example games demonstrating Lines, Ways, Cluster, Scatter, and Expanding Wilds mechanics. Use these as starting points or reference implementations for your own game. - [Lines game (0_0_lines)](https://mintlify.wiki/StakeEngine/math-sdk/examples/lines-game.md): A 3-row, 5-reel slot paying on 20 fixed paylines. Demonstrates wild multipliers that add together in freegame, a separate freegame reelset, and scatter-triggered freespins. - [Ways game (0_0_ways)](https://mintlify.wiki/StakeEngine/math-sdk/examples/ways-game.md): A 5-reel, 3-row ways game with 243 win ways. Wild multipliers compound multiplicatively in freegame, and Wilds are excluded from the first reel. - [Cluster game (0_0_cluster)](https://mintlify.wiki/StakeEngine/math-sdk/examples/cluster-game.md): A 7×7 tumbling cluster game. Freegame grid position multipliers start deactivated, activate at 1× on the first win, and double with each subsequent win at that position (up to 512×). - [Scatter game (0_0_scatter)](https://mintlify.wiki/StakeEngine/math-sdk/examples/scatter-game.md): A 6-reel, 5-row pay-anywhere tumbling game with a persistent freegame global multiplier and board multiplier symbols. Freespins are 2× the number of Scatters on board with no fixed upper limit. - [Optimization Algorithm](https://mintlify.wiki/StakeEngine/math-sdk/optimization/algorithm.md): How the Rust-powered win distribution optimizer adjusts simulation selection weights to target a specified RTP and hit-rate profile. - [Setting Up Optimization](https://mintlify.wiki/StakeEngine/math-sdk/optimization/setup.md): Configure OptimizationSetup with conditions, scaling, and parameters, then run the Rust optimizer against your simulation lookup tables. - [Game Analysis](https://mintlify.wiki/StakeEngine/math-sdk/optimization/analysis.md): Generate a PAR sheet and analyze the optimized win distribution, including per-symbol hit-rates, RTP contributions by win range, and game-type breakdowns. - [Config](https://mintlify.wiki/StakeEngine/math-sdk/api/config.md): Base configuration class for all game parameters. - [GameState](https://mintlify.wiki/StakeEngine/math-sdk/api/gamestate.md): Core simulation state class and execution entry point. - [Executables](https://mintlify.wiki/StakeEngine/math-sdk/api/executables.md): Reusable game logic and event emission functions. - [Events](https://mintlify.wiki/StakeEngine/math-sdk/api/events.md): Event emission functions for communicating game state to the frontend. - [Line Wins](https://mintlify.wiki/StakeEngine/math-sdk/api/lines.md): Evaluate payline-based winning combinations across a fixed set of defined lines. - [Ways Wins](https://mintlify.wiki/StakeEngine/math-sdk/api/ways.md): Evaluate all-ways winning combinations by counting matching symbols across adjacent reels. - [Cluster Wins](https://mintlify.wiki/StakeEngine/math-sdk/api/cluster.md): Evaluate wins based on connected groups of adjacent like-symbols anywhere on the board. - [Scatter Wins](https://mintlify.wiki/StakeEngine/math-sdk/api/scatter.md): Evaluate pay-anywhere wins where the total count of a symbol anywhere on the board determines the payout. - [Wallet Manager](https://mintlify.wiki/StakeEngine/math-sdk/api/wallet-manager.md): Track and accumulate wins at every level — per-reveal, per-spin, per-gametype, and across full simulations. - [Board](https://mintlify.wiki/StakeEngine/math-sdk/api/board.md): Generate and manage the active 2D grid of Symbol objects from reelstrips. - [Symbols](https://mintlify.wiki/StakeEngine/math-sdk/api/symbols.md): The Symbol class represents a single position on the game board, carrying its name, special attributes, and per-instance state. - [Utilities](https://mintlify.wiki/StakeEngine/math-sdk/api/utilities.md): General-purpose helper functions for randomness, game analysis, file verification, and lookup table management. ## OpenAPI Specs - [openapi](https://mintlify.wiki/StakeEngine/math-sdk/api-reference/openapi.json)