Markdown version: https://ai.hiina.space/reports/magic-circle-programming-languages/09-athanor-membrane-chemistry-where-sloppiness-is-wild.md · index

Index of everything on this site: https://ai.hiina.space/index.md

Magic circle programming languages: 9. Athanor: membrane chemistry where sloppiness is wild magic

9. Athanor: membrane chemistry where sloppiness is wild magic

Nested closed curves are membranes, and glyphs inside them are element tokens in a multiset, so order and position mean nothing, as with Magicka's queue for ordinary spells. Elements react by a priority table, opposing elements annihilating first and then combining. A membrane drawn with a gap dissolves once its contents go quiet, pouring them into the parent, so nesting is evaluation order: inner reactions finish before outer ones see the products. Here precision is semantic in the strongest sense, the design's deliberate exception to "graded, never a gate". Each drawn token denotes the recogniser's calibrated posterior over element classes, and casting samples from it. A neat glyph is near-certain; an ambiguous one sometimes casts as its confusable neighbour, and the glyph set is designed so neighbours are thematically close. You can preview the outcome distribution before you release.

Visual element Meaning
Closed curve (any shape) Membrane; region holding a multiset
Membrane with a gap Dissolvable: dissolves when its region is inert
Outermost membrane (skin) Its contents at halt are the spell's effect
Gap in the skin Backfire: effect lands on the caster
Element glyph One token; multiplicity = count of copies = magnitude
Recipe seal (circle split by a diameter; reactants left, products right) User rule; tangent to a membrane = local, in the outer legend band = global
Product drawn outside the recipe seal's rim Sent out to the parent region
Glyph posterior, sharpened by β Probability of each reading at cast time

Model and evaluation. This is a P system (Păun's membrane computing; with cooperative rules, P systems are computationally universal). A configuration is a membrane tree with a multiset in each region, and rules u → v sit in ordered priority tiers. In one step, in every region in parallel: for each tier in order, apply each rule in order as many times as possible to objects not yet consumed, holding products back until the step ends; then move products marked "out" to the parent region, or to the environment from the skin; then dissolve every gapped membrane whose region applied no rule and received nothing this step, merging its multiset into the parent and dropping its local rules. Halt when a step changes nothing; the output is the environment plus the skin's contents. Greedy application in rule order always yields a maximal multiset of applications, so this is a deterministic refinement of the usual nondeterministic maximal parallelism. Dissolving on inertness, rather than through Păun's explicit δ object, is the design's own variation, and δ can still be written as a product.

The built-in chemistry is Magicka-inspired, not Magicka's actual rules. Tier 1 holds the oppositions: F + C → ∅, W + L → ∅, L + E → ∅, Life + Arcane → ∅. Tier 2 holds combinations: W + F → S (steam), W + C → I (ice), S + L → Z (storm, invented). For precision, token i has posterior π_i(c) = softmax_c(−d_i(c)/τ) over $Q template distances, with τ fitted by temperature scaling (Guo et al. 2017) on held-out labelled drawings so the probabilities mean what they say. Casting samples each token from p_i(c) ∝ π_i(c)^β. β is the sharpness: β → ∞ gives argmax, a fully deterministic "steady" mode that doubles as the accessibility setting. A drawing therefore denotes a distribution over programs, and the effect is a distribution over output multisets, which the caster previews by enumerating the few uncertain tokens.

Worked example: "storm lance". The skin is a closed ring holding one lightning glyph ϟ and an inner gapped membrane. Inside that membrane are two water glyphs ≈ and two fire glyphs ▲.

   .--------------------------.
   |   ϟ                       |     skin (closed)
   |      .- - - - - - .       |
   |     (   ≈     ≈    )      |     inner membrane, gapped
   |     (   ▲     ▲    )      |
   |      '- - - - - - '       |
   '--------------------------'

Text form, with ? marking a gap: skin{ L, inner?{ W, W, F, F } }. With every token drawn cleanly:

Step What happens State
1 Inner region: W + F → S twice; the skin's {L} is inert inner {S, S}; skin {L}
2 Inner region is inert, so it dissolves skin {L, S, S}
3 Skin: S + L → Z skin {Z, S}
4 Nothing changes Halt; emit storm + steam

Draw the same tokens flat with no inner membrane, {L, W, W, F, F}, and tier 1 applies W + L → ∅ while tier 2 applies W + F → S, emitting {S, F}: steam and fire, no storm. The membrane is what kept water away from lightning until the water had become steam.

Now the wild-magic variant: one water glyph is drawn loosely, with posterior water 0.70, cold 0.25, life 0.05. In the cold case the inner region holds {W, C, F, F}; tier 1 applies F + C → ∅ and tier 2 applies W + F → S, and after dissolving, S + L → Z, so the output is {Z}, a weaker storm. In the life case the inner region yields {S, Life, F}; after dissolving, S + L → Z, so the output is {Z, Life, F}, a storm that heals and burns. At β = 1 the preview reads storm + steam 70%, storm 25%, storm + life + fire 5%. At β = 2 it reads 88%, 11% and 0.5%.

Mishaps. A gap in the skin is a backfire. User recipes that cycle hit the step budget, and the membranes bulge and pop (boil-over). If everything annihilates, the spell fizzles: a grey puff, paying only the cost of the attempt.

Parsing. In VR, membranes are closed strokes of any shape, containment is point-in-polygon on the projected plane, and a gap is endpoint separation over perimeter above a threshold; tokens get $Q posteriors. From an image this is the easiest structure of the five: OpenCV findContours with RETR_TREE returns the containment hierarchy directly, gaps show up as skeleton endpoints, and multiplicity is a connected-component count, which must not be left to a VLM. Small-glyph classification is the weak point, and the classifier must be calibrated, since raw CNN softmax and VLM "confidence" are not probabilities. The design rule is to choose glyph shapes so the recogniser's confusion matrix mirrors elemental adjacency (water near cold, fire near lightning), so wild magic produces plausible neighbours rather than noise. That rule is an inference and needs a confusion-matrix check on real drawings.

New versus borrowed. P systems (Păun), multiset rewriting (Gamma, by Banâtre and Le Métayer; the chemical abstract machine, by Berry and Boudol), Magicka's multisets and oppositions, Witch Hat Atelier's open ring and nesting, and Cultist Simulator's discovery by experiment are borrowed. The calibrated recogniser posterior as the execution distribution, confusions designed to be thematic, and inertness-triggered dissolution as sequencing are new. Untested: whether players read a 25% "wild" outcome as fun or as unfair; the preview is meant to make it a choice.


Text licensed CC BY 4.0 (attribution: Hiina, ai.hiina.space). Source: https://github.com/hiinaspace/ai-hiina-space