An Agent-Based Model of the Magical Girl System in Puella Magi Madoka Magica
Independent researcher
An independent study written for fun. It has not been peer reviewed, and every result is a property of the model under its stated assumptions. Corrections are welcome as GitHub issues.
We model the system connecting magical girls, witches and Kyubey in Puella Magi Madoka Magica as a closed resource cycle, and study its behaviour at the population level. Our simplification keeps five elements: soul gems accumulate corruption, corruption is cleansed using grief seeds left by defeated witches, a girl whose gem saturates becomes a witch, Kyubey collects the energy released by that transition, and new girls enter by contract. We implement this as a spatial agent-based model with explicit corruption accounting, endogenous recruitment, and hawk-dove contests over grief seeds.
Four results follow. First, lifetime corruption is dominated by conflict between magical girls rather than by combat with witches: when witches are rare the ratio is about 5.9 to 1, and it falls below 1 when witches are plentiful. Second, the rate at which girls leave the population is set by the contract rate and is insensitive to the grief seed supply; a richer witch supply changes how girls leave rather than how often, and the share of departures ending in transformation falls from 88% to 31%. Third, cumulative energy return is bounded by the rate at which new candidates become available, so the contract rate that maximises return decreases as the evaluation horizon lengthens: the early return is paid out of a stock that is consumed once, which is the structure of a Ponzi scheme. Fourth, aggression over grief seeds reproduces the tragedy of the commons: collective survival is highest near an aggression level of 0.15, but under scarcity slightly more aggressive strategies invade a less aggressive population.
Each result is a property of the model under the stated assumptions. We give the parameter ranges over which each holds and validate the implementation against an exact conservation identity.
Result 3 compares only fixed offer rates. Since the level of the candidate pool is observable state, a state-dependent policy ought to do better by throttling recruitment when the pool runs low and raising it once the pool recovers. We searched for such a policy with tabular Q-learning, a reinforcement-learning method, taking a macro-step of 100 days, six discrete offer rates, and the discount factor in place of the evaluation horizon.
The result is negative. At each of three discount factors, 2000 training episodes produced no policy that beats the best fixed rate.
| Discount factor | Learned policy | Best fixed rate | Difference |
|---|---|---|---|
| 0.9 | 229.7 | 242.3 | −5.2% |
| 0.99 | 209.0 | 242.3 | −13.8% |
| 0.999 | 180.0 | 242.3 | −25.7% |
This does not mean fixed rates are better. Two features of the setup limit what the experiment can show: cumulative return is nearly flat in the offer rate above 0.096, so the margin available to a state-dependent policy is smaller than the evaluation noise, and the learned tables are visibly under-fitted. The claim is therefore narrow: under this setup, a state-dependent policy shows no demonstrable advantage.
The environment is managed with uv. Replicates use deterministic seeds, so a rerun reproduces the reported numbers.
git clone https://github.com/yuna0x0/madoka-magica-abm.git
cd madoka-magica-abm
uv sync
uv run madoka-abm experiments # about three minutes on one core
The paper is built with Typst; the Chinese edition needs a CJK serif face (Noto Serif CJK TC by default).
@misc{hoshinomiya2026griefseed,
title = {The Grief Seed Economy: An Agent-Based Model of the Magical Girl
System in Puella Magi Madoka Magica},
author = {Hoshinomiya, Arisu},
year = {2026},
url = {https://madoka-magica-abm.pages.dev},
note = {Independent study, not peer reviewed. Code and data:
https://github.com/yuna0x0/madoka-magica-abm}
}