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.
Implementation and drafting relied on a large language model (Claude Opus 5, Anthropic). The research direction, the rules and the final decisions are the author's. Everything checkable by machine is verified; the modelling choices and interpretation have been reviewed by one non-specialist reader. See the paper's appendix, Reproduction and validation.
We model the system connecting magical girls (girls, hereafter), witches and Kyubey in Puella Magi Madoka Magica as a resource cycle and study its behaviour at the population level. Every rule we impose is taken from the setting: cleansing moves corruption into a grief seed rather than destroying it, a filled seed hatches into a witch unless Kyubey consumes it, a defeated witch leaves a seed only sometimes, a clouded gem saps its owner's combat power, and familiars mature into witches of their own. The parameters the setting fixes are set from it, and the rest are calibrated against three things the setting shows: a city holds a handful of magical girls, veterans run a few years, and most careers end in transformation.
Four results follow. First, at the density the setting shows, combat with witches dominates the corruption budget and conflict between girls is minor, a factor of 0.15; the ratio rises with density and passes parity only near nine standing girls, far above anything the setting depicts. Second, the rate at which girls leave is set by the contract rate and is insensitive to the seed supply, which instead changes how they leave and how much Kyubey collects. Third, cumulative return saturates in the offer rate. The advantage aggressive recruitment buys is temporary, because it comes from a stock that can only be spent once, which is the structure of a Ponzi scheme. Fourth, a city closed to migration has only two outcomes: the girls starve for want of seeds, or familiars multiply and the city is lost; the first is also where Kyubey's return is highest.
Each result is a property of the model under the stated assumptions, and we 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, though the margin is small. 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 | 46.3 | 47.6 | −2.8% |
| 0.99 | 45.3 | 47.6 | −4.9% |
| 0.999 | 46.5 | 47.6 | −2.4% |
This does not mean fixed rates are better. It means the return is capped by the rate at which candidates arrive: fixed rates already plateau above 0.016, the learned policies sit on that plateau, and the learning curve shows no upward trend after episode 200. The claim is therefore narrow: under this setup, a policy that adjusts with the state shows no demonstrable advantage.
In the setting a familiar carries no grief seed, but one that feeds on enough humans matures into a witch that may. Leaving familiars alive until they mature is therefore a named practice, witch farming, and characters argue about it. The baseline folds familiars into a maturation rate, so the model has no such choice in it. Here they are individuals again: they take humans, they die when their parent witch is defeated, and culling one yields nothing. We sweep the share of girls who farm.
Farming raises the seed supply and buys nothing with it. Realised maturation rises by a factor of 4.3, while both career length and Kyubey's return stay within replicate noise. What rises is the cost nobody in the loop is counting.
| Share farming | Maturation rate | Median career | Kyubey's return | Humans lost / 1000 days |
|---|---|---|---|---|
| 0 | 0.00222 | 116 | 35.4 | 16.3 |
| 0.5 | 0.00379 | 115 | 35.9 | 18.3 |
| 1 | 0.00949 | 106 | 34.0 | 24.6 |
The reason is the one behind Result 3: the return is limited by the rate at which candidates arrive, not by the seed supply. Career length does not move because the extra seeds arrive attached to extra witches. This is an accounting result at the level of the population rather than a claim about any individual girl.
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 a minute 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, Yuna},
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}
}