Skip to main content

get_random_outcome()

The primary randomness function used throughout the SDK. Performs a weighted random draw from a dictionary mapping outcomes to weights.
dict
required
A dictionary of {outcome: weight} pairs. Weights can be any positive numeric values — they do not need to sum to 1.
float
default:"None"
Pre-computed sum of all weights. Pass this to avoid recomputing it on every call in tight loops. If None, the sum is computed internally.
Returns one outcome key from the distribution, selected with probability proportional to its weight.

Usage examples

get_random_outcome() uses random.uniform internally. For reproducible results in testing, seed Python’s random module before calling it: random.seed(42).

Statistical helpers

get_mean_std_median(dist)

Computes descriptive statistics from an ordered win-distribution dictionary.
dict
required
A {win_value: count} dictionary representing a win distribution (e.g. from a lookup table).
Returns (mean, std_dev, median) as a tuple of floats.

normalize(distribution)

Normalizes all weight values in a distribution in-place so they sum to 1.0. Modifies the dictionary directly.

PAR sheet generation — run_analysis.py

The run() function in run_analysis.py generates a .xlsx PAR sheet from an optimized lookup table.
dict
required
An optimized lookup table as generated by the optimization algorithm. Expected format matches the segmented lookup table structure.
dict
required
Contents of force_record_<mode>.json. Each entry must include at minimum "symbol" and "kind" keys.
dict
required
config.paytable dict. Valid symbol names are extracted from this to filter analysis.
list
default:"[]"
Additional gamestate.record() keys to include in the analysis output. Allows hit-rate reporting for custom events beyond symbol wins.
The output .xlsx file contains:
  • Hit-rates per win range, split by gametype
  • RTP contribution per win range
  • Simulation counts per win range
  • Average payout multiplier per win range

Swap lookups

The optimization algorithm outputs multiple candidate lookup tables under <game>/library/optimization_files/. The swap_lookups utility provides functions to copy weights from a candidate file into the active lookUpTable_<mode>_0.csv file.
This allows switching between optimization variants without manually editing the lookup table.

File integrity verification

get_file_hash(filepath)

Prints the SHA-256 hash of a single file to the console. Used to verify a file’s contents match the value recorded in config.json.

Directory hash

A companion function prints SHA-256 hashes for all non-Python files within a specified directory. Use this to verify the integrity of an entire game library folder against recorded hash values in config.json.
Run file hash verification before and after any game file deployment to confirm that reelstrips, lookup tables, and configuration files have not been altered.