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 provides four win evaluation methods. You select one by setting config.win_type in your GameConfig, then call the corresponding function from within run_spin() or run_freespin(). All four methods return the same win_data structure, so wallet manager updates and event emission are consistent regardless of which method you use.

The win_data structure

Every win evaluation function returns:
win_data = {
    "totalWin": float,   # sum of all wins for this board state
    "wins": [
        {
            "symbol":    str,   # winning symbol name
            "kind":      int,   # number of matching symbols
            "win":       float, # payout amount (after multipliers)
            "positions": list,  # [{"reel": int, "row": int}, ...]
            "meta":      dict,  # method-specific extra data
        },
        ...
    ]
}
The positions key is required for the predefined win event functions to correctly adjust row numbers when padding symbols are in use.

Multiplier strategies

All win methods integrate with apply_mult() from src.wins.multiplier_strategy. Three strategies are available:
StrategyBehaviour
"global"Multiplies the base win by a single global_multiplier value
"symbol"Sums multiplier attributes on winning symbol positions; multiplied by symbol count for ways games
"combined"Applies both symbol and global multipliers together
Pass the strategy when calling the win function:
win_data = Lines.get_lines(
    self.board,
    self.config,
    multiplier_method="symbol",
    global_multiplier=self.global_mult,
)
The resulting meta dict includes multiplier, winWithoutMult, globalMult, and lineMultiplier (for lines) or symbolMult and ways (for ways), giving the frontend full detail to display the win breakdown.

Lines wins

Lines games pay on fixed paylines. Each payline is an array of row indices — one per reel — that defines a path across the board.

Paylines configuration

Define paylines in config.paylines as a dict from line index to row array:
game_config.py
self.paylines = {
    0:  [0, 0, 0, 0, 0],  # top row
    1:  [1, 1, 1, 1, 1],  # middle row
    2:  [2, 2, 2, 2, 2],  # bottom row
    3:  [0, 1, 2, 1, 0],  # V-shape
    4:  [2, 1, 0, 1, 2],  # inverted V
    # ... up to N paylines
}

Calling get_lines()

gamestate.py
self.win_data = Lines.get_lines(
    board=self.board,
    config=self.config,
    wild_key="wild",           # attribute name for wild symbols
    wild_sym="W",              # symbol name for wild-only wins
    multiplier_method="symbol",
    global_multiplier=self.global_mult,
)
self.win_manager.update_spinwin(self.win_data["totalWin"])
Lines.emit_linewin_events(self)

Wild substitution

Wilds substitute for any non-wild symbol. When a payline begins with one or more wilds followed by a non-wild symbol, the engine evaluates both the wild-only win and the substituted win, taking whichever pays more:
  • Payline [W, W, W, L4, L4] evaluates (3, "W") vs (5, "L4") and keeps the higher payout.
Wilds on the first reel do not trigger substitution — only wild-then-symbol sequences from left to right are evaluated. A common approach is to define wild symbols to pay only for complete lines (e.g. 5-of-a-kind wilds only), avoiding ambiguous comparisons.

Lines meta fields

"meta": {
    "lineIndex":       int,   # payline index from config.paylines
    "multiplier":      int,   # total multiplier applied
    "winWithoutMult": float,  # base win before multipliers
    "globalMult":      int,   # global multiplier component
    "lineMultiplier":  int,   # per-symbol multiplier component
}

Choosing a win type

Lines

Fixed paylines on a rectangular grid. Best for traditional slot formats with a defined number of win paths.

Ways

All combinations across consecutive reels. Higher hit-rate than lines on the same board size.

Cluster

Adjacent symbol groups. Common with tumble mechanics and large, irregular boards.

Scatter

Total symbol count anywhere on board. Pairs naturally with cascading grids and high symbol counts.

Game Configuration

Set win_type and configure the paytable for your chosen method.

Game Events

Emit win events after calling a win evaluation function.

Lines API reference

Full Lines class method reference.

Ways API reference

Full Ways class method reference.

Build docs developers (and LLMs) love