forked from StakeEngine/math-sdk
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Richard Fu edited this page Jan 16, 2026
·
2 revisions
Welcome to the Stake Engine Math SDK wiki! This Python-based framework is designed for defining slot game rules, simulating outcomes at scale, and optimizing win distributions.
- Running Games - How to run simulations and generate books
- Game Structure - Understanding the architecture
- Testing - Writing and running tests
- Event System - Working with the standardized event system
- Optimization Guide - Using the Rust optimization algorithm
- Migration History - Evolution from fork to refactored architecture
- Performance Analysis - Profiling and optimization results
- Performance Optimization Results - Detailed speedup analysis
- Compression Benchmarks - Output optimization metrics
- Event Audit - Complete event type inventory
- Full Documentation Index - Complete documentation overview
- GitHub Repository - Source code and issues
- Latest Release (v2.0.0) - Download and release notes
The SDK underwent a comprehensive refactoring and optimization:
- 67% reduction in inheritance complexity (6 โ 2 layers)
- 75% reduction in files per game (4 โ 1 file)
- 180+ type hints with comprehensive docstrings
- Custom exception hierarchy and standardized constants
- 35-40% smaller files via compression + event filtering
- 13% faster generation with compact mode
- Fully backward compatible, RGS verified
- 35-47% simulation speedup via paytable caching
- 287 sims/sec average (up from 204 sims/sec)
- Built-in profiling tools
# Clone repository
git clone https://github.com/Raw-Fun-Gaming/stake-engine-math.git
cd stake-engine-math
# Setup environment
make setup
source env/bin/activate# Run a sample game
make run GAME=template_cluster
# Books files generated in:
# games/template_cluster/build/books/Simulation results stored as JSON/JSONL files containing:
- board - The reel strip result (symbol grid)
- events - Game events (wins, triggers, multipliers)
- payout_multiplier - Total win amount
Games have different modes (base/bonus) with their own:
- Reel strips and distributions
- Win calculation logic
- Probability weights
Event-driven architecture using EventConstants:
- WIN, REVEAL, TRIGGER_FREE_SPINS, etc.
- Standardized types prevent errors
- Event filtering for size optimization
Rust genetic algorithm adjusts distributions to meet:
- RTP (Return to Player) targets
- Hit Rate (win frequency) goals
- Average Win constraints
- Custom search conditions
stake-engine-math/
โโโ docs/ # Documentation (this wiki)
โโโ games/ # Individual game implementations
โโโ src/ # Core SDK modules
โ โโโ calculations/ # Win algorithms (cluster/lines/ways/scatter)
โ โโโ config/ # Configuration system
โ โโโ events/ # Event system with filtering
โ โโโ output/ # Output optimization
โ โโโ state/ # Core state machine
โโโ optimization_program/ # Rust optimization engine
โโโ tests/ # 54 tests (all passing)
โโโ scripts/ # Helper tools
make run GAME=tower_treasuresIn game_config.py:
from src.output.output_formatter import OutputMode
config.output_mode = OutputMode.COMPACT # 27.9% smaller
config.skip_derived_wins = True # Additional 10-15% reductionmake unit-test GAME=tower_treasures # Game-specific
make test # Full SDK tests
make coverage # Coverage reportmake profile GAME=tower_treasures
make benchmark GAME=template_lines- GitHub Repository: https://github.com/Raw-Fun-Gaming/stake-engine-math
- Latest Release: https://github.com/Raw-Fun-Gaming/stake-engine-math/releases/tag/v2.0.0
- Issues: https://github.com/Raw-Fun-Gaming/stake-engine-math/issues
- PyPI Package: https://pypi.org/project/stake-engine-math/ (coming soon)
Current: v2.0.0 (January 2026)
See the Migration History page for complete refactoring details.
Ready to get started? Jump to Running Games to run your first simulation! ๐ฐ