Game analysis produces an Excel (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.
.xlsx) PAR sheet summarizing key statistics of the optimized win distribution. It is designed to be run after optimization is complete.
Prerequisites
- A completed optimization run — analysis uses the optimized lookup tables (
lookUpTable_<mode>_0.csv), not the raw simulation output. force_record_<mode>.jsonfiles inlibrary/forces/, containing the event data recorded during simulation.GameConfig.paytablepopulated with symbol names so the analysis can resolvekind/symbolpairs to readable names.
For meaningful statistics, run at least 100,000 simulations per mode before analyzing. Smaller batches produce noisy hit-rate and RTP estimates that are not representative of the final game distribution.
Enabling analysis in run.py
Setrun_analysis to True in the run_conditions dictionary:
create_stat_sheet after the optimization step:
What the analysis uses
| Source | Purpose |
|---|---|
lookUpTableSegmented_<mode>.csv | Determines which game type (basegame, freegame) contributed to each simulation’s final win |
force_record_<mode>.json | Provides event frequencies — symbol, kind, mult, gametype per recorded win |
GameConfig.paytable | Maps (kind, symbol) pairs to payout amounts and provides valid symbol names |
Lines class records wins as:
The run() function and custom search keys
Therun() function inside run_analysis.py accepts an optional custom_keys argument. Each entry is a dictionary matching fields in gamestate.record() calls — the analysis will compute hit-rates specifically for events matching those keys.
PAR sheet output
The generated.xlsx file contains:
- Per-symbol hit-rates — frequency of each
(kind, symbol)combination, using symbol names fromGameConfig.paytable. - Per-range RTP contributions — how much each win-range bucket contributes to total RTP.
- Simulation counts by win range — how many simulations fall into each range, useful for checking distribution coverage.
- Game-type breakdown — hit-rates and RTP split by
basegamevsfreegame, sourced fromlookUpTableSegmented_<mode>.csvand thegametypefield in force records.
Analyzing win distributions
Once a lookup table has been optimized, you can inspect the resulting win distribution — a dictionary where keys are all unique, ordered payout values and values are the probability of obtaining each payout.Comparing alternative lookup tables
The optimization algorithm outputs several viable candidate lookup tables tolibrary/optimization_files/. The swap_lookups utility lets you swap out the weights in lookUpTable_<mode>_0.csv with weights from any of these candidates, so you can compare how different distributions perform without re-running the optimizer.
File hash checking
Useget_file_hash() to print the SHA-256 value of a file or all non-Python files in a directory. Compare these values against the SHA values stored in config.json to verify that file contents have not been altered since the configs were generated.
Understanding runtime RTP output
During a simulation or optimization run, each thread prints a summary line when it finishes:Next steps
Optimization algorithm
Learn how the optimizer adjusts weights to hit the RTP target.
Setting up optimization
Configure conditions, scaling, and parameters for your game.
