A local Tetris game runner for bots that implement the Stacker Bot Protocol (SBP).
Minorail provides an SBP bot a complete local game to play against. Minorail owns the board, active piece, queue, hold state, rules, and sequence numbers, while the bot focuses on choosing placements. It can reconcile queue and board state across requests, repair desyncs when observed state changes unexpectedly, generate movement paths for selected placements.
Minorail also exposes the same suggestion flow over websockets, allowing you to easily connect real game clients to your SBP bot by sending game state updates to Minorail's websocket API.
| Feature | What it does |
|---|---|
| Solo local Tetris game | Runs one board, active piece, queue, hold, line clears, combo, and back to back state. |
| Battle mode | Runs two SBP bots against each other with configurable attack calculators and garbage rules. |
| SBP bot runner | Starts an SBP bot subprocess and exchanges rules, start, suggest, play, new_piece, stop, and quit messages. |
| Terminal visualizer | Shows a local game directly in the terminal. |
| Web visualizer | Provides a browser based view for watching games and inspecting state. |
| Headless runs | Runs batches without rendering for testing or benchmarking. |
| Evaluation output | Writes JSON summaries and lock-by-lock events for batch analysis. |
| Websocket API | Serves Minorail suggestions to external clients while keeping per session state. |
| Session reconciliation | Treats incoming snapshots as authoritative and resets or advances the bot session as needed. |
| Piece stream tracking | Keeps generated piece chronology aligned for bots that support SBP piece_stream. |
| Path output | Finds input paths to selected placements and can convert sonic drops to soft drops. |
| Rule settings | Supports randomizer, kickset, 180s, sonic drop mode, all spin back to back, perfect-clear back to back, and spawn position settings. |
Detailed documentation is available here:
https://ruelalarcon.github.io/minorail/
SBP protocol documentation is available here:
https://github.com/ruelalarcon/stacker_bot_protocol
Minorail requires Python 3.11 or newer.
pip install -r requirements.txtRun one game with the terminal visualizer:
python minorail.py solo play "path/to/sbp-bot"Run with the web visualizer:
python minorail.py solo play "path/to/sbp-bot" --webRun a headless batch:
python minorail.py solo play "path/to/sbp-bot" --headless --games 100Run a JSON evaluation batch:
python minorail.py solo eval "path/to/sbp-bot" --games 100 --seed 123 --json-out results.jsonLimit a run by accepted piece locks or wall-clock time:
python minorail.py solo eval "path/to/sbp-bot" --games 100 --piece-limit 1000 --time-limit-ms 30000Run a two-bot battle:
python minorail.py battle play "path/to/bot-a" "path/to/bot-b"Run a battle in the web visualizer:
python minorail.py battle play "path/to/bot-a" "path/to/bot-b" --webRun multiple battle games while reusing the two bot processes:
python minorail.py battle play "path/to/bot-a" "path/to/bot-b" --games 20Run battle evaluation:
python minorail.py battle eval "path/to/bot-a" "path/to/bot-b" --games 100 --json-out battle-results.jsonStart the websocket API:
python minorail.py solo ws "path/to/sbp-bot"Minorail reads settings.toml by default. Use --settings to load another
file:
python minorail.py solo play "path/to/sbp-bot" --settings custom-settings.tomlSettings cover gameplay rules, bot timeouts, queue refill behavior, pathfinding, bot info logging, and visualizer timing.
Run tests:
python -m pytestRun lint and type checks:
./lint.shOn Windows PowerShell:
.\lint.ps1