Skip to main content

magsim - A Magical Athlete Simulator

A fan-made Python simulation engine and analysis toolkit for the board game Magical Athlete.

Python CI License

✨ View Interactive Dashboard ✨

BoardGameGeek · CMYK Games · Designer Diary · Art Blog


What is this?

Magical Athlete is a draft-based racing board game where you roll a die to move, but every racer has a game-breaking, unique ability.

magsim translates the physical game into a high-performance Python engine. Capable of running 60+ full races per second with complete state logging, it allows you to:

  • Simulate Races: Run single game simulations in the command line or UI
  • Data Generation: Run high-volume batch simulations to generate datasets for analysis
  • Visual Analytics: Visualize races and analyze aggregated data in an interactive web dashboard that runs fully in your browser (Pyodide)
  • A/B Experiments: Pit Smart AI against Random AI, compare the impact of racers and measure modifying rules changes the balance via the CLI tool

Quickstart

The fastest way to use magsim is via the web app. Python runs in your browser (Pyodide), so the first load downloads the runtime.

To run magsim locally, I recommend using uv (Install uv here).

1. Run a single test race:

uvx magsim game

2. Run a game with specific configuration:

uvx magsim game -n 6 -b standard -r Egg Magician

3. Launch the interactive dashboard locally:

uvx magsim gui

Command Line Interface

magsim ships with a powerful CLI for running simulations, conducting A/B testing, and generating datasets.


magsim game

Run a single game simulation. If no board or racers are specified, the engine will pick defaults and a random seed.

Option Flag Description
Racers -r, --racers Space-separated list of racer names to include.
Player Count -n, --number Target number of racers. Roster is filled with unique randoms if fewer are provided.
Board -b, --board The name of the board to race on.
RNG Seed -s, --seed Integer seed for reproducible races.
Config File -c, --config Path to a TOML configuration file.
Encoding -e, --encoding Base64 encoded configuration string.
House Rules -H, --houserule Repeatable key-value pairs for custom rules (e.g., start_pos=5).
Max Turns --max-turns Safety cutoff for infinite loops. (Default: 200)

Config Precedence: 1. CLI Args ➔ 2. Base64 Encoding ➔ 3. TOML Config ➔ 4. Defaults

Examples:

# Basic quickstart
magsim game -n 6 -b WildWilds

# Specific matchups with a fixed seed
magsim game -r Mouth BabaYaga -n 5 -s 123

magsim batch

Run high-volume batch simulations driven by a TOML configuration. Saves results to .parquet files for the frontend dashboard.

Option Flag Description
Config <path> (Required) Path to the TOML simulation config file.
Runs --runs Override the number of runs per combination.
Max Runs --max Override the maximum total runs across the batch.
Turn Limit --turns Override the max turns per race.
Seed Offset --seed-offset Offset for RNG seeds to prevent overlap. (Default: 0)
Results Dir --results-dir Where the database and Parquet files go. (Default: results)
Force -f, --force Delete existing Parquet/DuckDB files in the results directory without prompting.

The config can name required_racers: those racers are in every game and the rest of each team is drawn from the pool (see configs/mush_only.toml).

Examples:

magsim batch configs/sim.toml --runs 50 --max 100000 
magsim batch configs/sim.toml --force

magsim compare

Run comparative A/B experiments. Appends run histories to Parquet files in results/. All commands accept -n (total games) and -o (save markdown report to path).

Command Target Description
ai <RACER> Pits a Smart AI against a Baseline Random AI.
rule <k=v> Default rules vs a modified setting.
racer <RACER> The overall impact of one specific racer on the field.

Examples:

# Test how 'Mouth' performs with Smart AI vs Random AI over 1000 games
magsim compare ai Mouth -n 1000 -o results/ai_mouth.md

# Evaluate the impact of a house rule (e.g., Mastermind steals 1st place)
magsim compare rule hr_mastermind_steal_1st=True -n 2000

# See how 'BabaYaga' warps the win rates of the rest of the field
magsim compare racer BabaYaga -n 3000

magsim recompute

Internal data analysis and aggregation tools. Both commands accept -f, --folder to target a specific data directory (Default: results/).

Command Description Example
aggregate Recomputes internal statistical aggregates. magsim recompute aggregate
stats Generates a fresh racer_stats.json file. magsim recompute stats -f custom_results/

magsim gui

Instantly launch the interactive simulation analysis dashboard.

magsim gui

🖥️ Run GUI Locally

If you want to modify the dashboard or analyze custom datasets, you can run the project locally from a cloned repository.

1. Clone the repository:

git clone https://github.com/pschonev/magical-athlete-simulator.git
cd magical-athlete-simulator

2. Generate your custom dataset:

magsim batch configs/sim.toml

The dashboard's own dataset takes two runs, which one command does (it replaces results/ and results_mush/):

uv run poe batch       # main batch (configs/twisty_oversampled.toml) + Mush-only games + Mush's merged power pairs + AI comparison
uv run poe mush        # only the Mush-only games and the pairs, when the main batch already exists
uv run poe ai-compare  # only the smart-vs-baseline AI comparison (results/ai_compare.parquet; `-- --games 500 --racers Banana Mastermind` for a quick run)

The AI comparison plays every racer with decisions (except Cheatah, whose outcome depends on the guesser's model of the pick, so a fixed baseline is not comparable) over the same games twice, once with simple fixed choices and once with the smart AI, one process per racer. poe web-build ships it (and the Second Wind winners & losers table, computed from results/) as small JSON files in the Fun facts tab; both are hidden for uploaded datasets. Mush's power pairs need far more Mush games than a uniform batch holds. The Mush-only games go to results_mush/ and are never merged into results/, because they would make Mush a third of all races and tilt every other statistic. Only a small table of pairs (results/mush_pairs.parquet, about 10 KB) is merged and shipped with the dashboard; poe release-prep copies it into the committed docs/results snapshot next to the two datasets. A dataset you upload in the dashboard has no such table, so its Mush charts use only its own Mush games (and stay empty without enough of them).

3. Build and start the dashboard with your results:

uv run poe web-build   # uses results/ if present (error if incomplete), else the committed docs/results snapshot
uv run magsim gui      # serves web/dist locally; without a build it opens the hosted app

Requires Node.js. During development use uv run poe web-dev instead.


Changelog

See the CHANGELOG.md for version history.

Metadata

Release files for magsim 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magsim 2.0.0
File Size Uploaded Provenance Actions
magsim-2.0.0.tar.gz 161.7 kB Without provenance Details for magsim-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for magsim 2.0.0
File Interpreter ABI Platform Actions
magsim-2.0.0-py3-none-any.whl Python 3 none any Details for magsim-2.0.0-py3-none-any.whl

Total release size: 406.1 kB

Release files / magsim-2.0.0.tar.gz

Download URL magsim-2.0.0.tar.gz
Size 161.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7f1ed0710a8c1f8f87a4cc4c5dafe8d9731a1819bd7fd6bc513cfd9367e3e5ec
BLAKE2b-256 checksum
How to use checksums
4d581642861c98fb2143c309b26f0173fdc644bb4c6cc06fcc80fe27189ae89c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / magsim-2.0.0-py3-none-any.whl

Download URL magsim-2.0.0-py3-none-any.whl
Size 244.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74c117f99b077df1456b9a37d7a3f352c383d88c051f75f650c9bed4a2f3285c
BLAKE2b-256 checksum
How to use checksums
b124a7e2d1469c3dddff68af10948ebfe91e30bdb2c5d29ceda1d030a07c3fd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for magsim 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page