Overview
Stake Engine requires games to consist entirely of static, pre-computed files. There is no server-side game logic executed at play time. All possible game outcomes must be generated ahead of time and stored in compressed files before a game can be published.
play/ API. The math SDK handles generating all of these files from your game logic.
Books format
Books are JSONL files (one JSON object per line) stored inlibrary/books/ (uncompressed) or library/books_compressed/ (compressed). Each line represents a single simulation result, keyed by simulation ID.
Each simulation object has the following structure:
0_0_lines sample game. The events array tells the frontend which symbols to reveal, the winning positions and amounts, and how to update the win counters. The payoutMultiplier is the final payout amount for the round.
Each event has an index (its position in the sequence), a type string identifier, and additional fields carrying the state snapshot for that moment in the round.
Lookup table format
Lookup tables are stored as CSV files inlibrary/lookup_tables/. They summarise the payout for every simulation and are consumed by the optimization algorithm to adjust selection weights so the game achieves its target RTP.
Example row:
58,1,10 — simulation 58, weight 1, payout multiplier 10×. This matches the payoutMultiplier value in the books file for the same simulation.
File naming follows the convention:
lookUpTable_<mode>.csv— initial table generated by the simulatorlookUpTable_<mode>_0.csv— optimized table with adjusted weightslookUpTableIdToCriteria_<mode>.csv— maps each simulation to its distribution criteria (e.g. max-win, 0-win, freegame)lookUpTableSegmented_<mode>.csv— breaks down which game type (basegame/freegame) contributed to the final payout
The play/ API response
When a player initiates a round, the RGS:
- Reads the lookup table for the active bet mode.
- Selects a simulation number at random, weighted proportionally by each row’s
Weightvalue. - Retrieves the corresponding entry from the books file.
- Returns the
eventsarray in the API response body.
events array. It must handle every event type in the sequence to render the full round correctly.
Compressed vs uncompressed format
Thecompression flag in run.py controls the output format:
Publishing to the RGS
All files required for RGS publication are written tolibrary/publish_files/. This folder contains the books, lookup tables, and an index file. Even if you generate your math results outside of this SDK, you must provide files in a compatible format in this folder structure to upload via the Admin Control Panel (ACP).