A more easily programmable system constructible in Magic: the Gathering

Introduction

Previously, Alex Churchill figured out a way to create a Turing machine within a game of Magic: the Gathering. Initially, it had the flaw of requiring players to always make certain choices to keep the machine running. Over time, it was improved, gradually removing those choices until it was fully automatic.

However, a Turing machine is a very basic computer design, created mainly for theoretical analysis. Because of that, it is difficult to directly program, and tends to require large numbers of steps for computations. Can we improve on that?

Yes, we can. Here is a system that can be constructed in a game of Magic: the Gathering that implements a machine language with a lot more functionality.

Structure

The program

The program is a cyclic sequence of the following cards: Plains, Island, Swamp, Mountain, Forest, Wastes, Snow-Covered Plains, Snow-Covered Island, Snow-Covered Swamp, Snow-Covered Mountain, Snow-Covered Forest, and Snow-Covered Wastes (for a version that is legal before Modern Horizons 3, use Persistent Petitioners instead). These cards are numbered 0, 1, 2, ..., 11 in the order listed.

Most of the time, one of the cards in the program will be on the battlefield under Alice's control; we call this card the program permanent. The rest of the cards will be in Alice's library, in program order from top to bottom.

The program is made up of instructions that each consist of 3 cards. X, Y, and Z shall refer to the numbers of the three cards that form the instruction currently being executed, in that order.

Controlling combat

Grand Melee forces all allowed attacks and blocks. Stormtide Leviathan restricts attacking creatures to those with flying or islandwalk; the latter will be unblockable under Bob's control, because Alice will usually control an Island.

Advancing through the program

A;Vaevictis Asmadi, the Dire;=1/1 Sliver;+Beast;+Reflection;ec attacks in Alice's combat phase. Its ability is forced (details later) to target the program permanent for Alice, and one particular permanent (details later) for Bob. When it resolves, Alice sacrifices the program permanent, and Wheel of Sun and Moon;.enchanting Alice sends it to the bottom of Alice's library, and then the next card (on top of Alice's library) is put onto the battlefield, becoming the new program permanent. Meanwhile, B;Tajuru Preserver stops Bob's permanent from being sacrificed, and thus Bob does not reveal the top card of his library.

The conditional mechanism

For each of the basic land cards, letting n be its number, we choose a creature type Xn and have A;Dralnu's Crusade;ad-cf;=Sliver;=2/1;ec;*Xn~Saproling equipped with a Strata Scythe imprinted with that card. These will all also attack, and the one corresponding to the current program permanent will be boosted to 3/2; A;Tetsuko Umezawa, Fugitive ensures that the others can't be blocked (as well as the previously mentioned Vaevictis Asmadi, the Dire). B;Dream Fighter;reach;+Sliver blocks the 3/2 Dralnu's Crusade, and they both phase out, so that creatures of the type corresponding to the current program permanent are no longer made Saprolings.

If we are using Persistent Petitioners as the 12th card, it is not a land at first, but we can make it a land, using A;Unknown Shores made a creature by Awakening of Vitu-Ghazi and enchanted with A;Infinite Reflection, and then add a 12th setup as above. (Note that Awakening of Vitu-Ghazi changes the name as well, avoiding an extra count for the Strata Scythe. The choice of Unknown Shores is mostly arbitrary.)

Life and Limb makes Saprolings into lands, and also makes them green, and then Blood Sun removes their abilities.

This reads the first card of an instruction; creatures of the corresponding type will keep their abilities. We also choose another creature type X* and have Dralnu's Crusade;*X*~Saproling;+artifact, attached to the Dream Fighter, with the attachment being made possible by Bludgeon Brawl, so that creatures of type X* get to keep their abilities after the first card is read, no matter what it is, until Bob's untap step comes around and the Dream Fighter phases back in.

We will also often want to use this conditional mechanism on noncreature permanents; to do that, we make them creatures using Urza, Prince of Kroog, combined with Argent Mutation if necessary.

Also, Shadow Sliver keeps these separate in combat from other creatures.

Reading the second and third cards

A;Bloodthirster;=1/1 Sliver;+Beast;+Reflection;ec;double strike also attacks, and adds two more combat phases. The second combat phase is used to read the second card, using another copy of the above setup: a second Vaevictis Asmadi, the Dire to advance through the program, a second Dream Fighter, and another batch of Dralnu's Crusades for another 13 creature types Y0, Y1, ..., Y11, and Y*. All the creatures there are given the creature type X* so that they do not attack or block in the first combat phase.

Similarly, the third combat phase is used by another copy of the setup (with creature type Y*) to make another 13 creature types Z0, Z1, ..., Z11, and Z* conditional on the third card of the instruction.

Constraining targets

Almost all creatures will be green; any creature that isn't naturally green and isn't specified to be differently colored is made green by Prismatic Lace. A few creatures will be red or blue, but even those are made green while inactive by Life and Limb.

A;Masked Gorgon;*green, blue, Reflection means that only red creatures are legal targets for Reflections' abilities. Similarly, A;Masked Gorgon;*green, red, Beast means that only blue creatures are legal targets for Beasts' abilities.

We will refer to the creature types Reflection and Beast as tR and tU respectively, indicating their function.

Each Vaevictis Asmadi, the Dire has been made both a Beast and a Reflection, so that green creatures, blue creatures, and red creatures are all illegal targets for it; the intended target for Alice is a noncreature land. The same types have been applied to the Bloodthirster for a different purpose, to stop it from blocking (which is something else protection does), because it untaps itself and stays untapped as it cannot attack in the later combat phases.

Spectral Guardian makes noncreature artifacts illegal targets for anything. A;Sterling Grove;+artifact and B;Sterling Grove;pro.-blue make other enchantments illegal targets for anything; Bob's one does not itself have shroud, and thus it is Bob's target for Vaevictis Asmadi, the Dire, while the protection from blue will be useful later to stop some other things from targeting it.

AB;Ivory Mask make both players illegal targets for anything.

Order of continuous effects, and one more of them

The continuous effects we have are timestamped as follows:

Layer 7b (base P/T) Layer 4 (types) Layer 5 (colors) Layer 6 (abilities)
Default Default Default Default
Dralnu's Crusades Blood Sun
Life and Limb Protection-granting and
shroud-granting effects

Most of the effects are applied in this order, with no dependencies that change the order. The exception is in layer 6, where abilities that will be removed by the Blood Sun wait for it to be applied (and thus end up not being applied themselves).

We also have A;Illusionary Terrain;+creature +Z*;ec;:Island→Island, within ① after the Stormtide Leviathan, so that the program permanent's subtype is set to only Island (except if it's Persistent PetitionersUnknown Shores, which is already just a Island after applying the Stormtide Leviathan's effect); this makes sure that the Life and Limb does not make it a creature. (Note that, because there are no Saprolings before ②, the Stormtide Leviathan does not have a dependency on the Life and Limb.)

By being made a Z*, this Illusionary Terrain has its abilities removed by Blood Sun most of the time, most importantly during Alice's upkeep. Because the effect of setting basic lands' types is applied in layer 4, before the abilities are removed in layer 6, it still functions despite the abilities being removed. However, the removal of abilities does shut off its cumulative upkeep.

Registers

There are twelve registers named r0, r1, ..., r11, each of which holds a nonnegative integer value.

Each register rn is a B;Joraga Warcaller;=Zn;ec;ind;=2/2;-2/-0;+Rabbit;vigilance, with its value in +1/+1 counters. Thus, rZ adds its value to the power and toughness of Elves that Bob controls (which does not include the other registers; their Elf type is overwritten).

Note that each register's power is equal to its value, whether it is rZ (having base power 2) or not (having base power 1 from the Life and Limb and +1 power from a Dralnu's Crusade).

All the registers are made red by Prismatic Lace at timestamp ④, later than that of the Life and Limb, so that they are always red even when inactive.

r0 also has Rhino added to its creature types; this will be useful for some instructions that use specifically this register.

For each n=0, 1, ..., 11, we have a B;Riders of Gavony;mv0;=artifact;ec;*Zn;:Yeti attached to the Dralnu's Crusade that applies to Yn, so that they phase out together. In particular, this means that each register except for rY has protection from Yetis. Then, a creature can be given the types Reflection and Yeti so that it can only target rY; we call this combination trY.

B;Riders of Gavony;*Saproling;:Zubera gives the inactive registers (those other than rZ) protection from Zuberas. Then, as above, creature types Reflection and Zubera together mean that a creature can only target rZ; we call this combination trZ.

The flag

There is a Boolean flag that some instructions use. It is represented by a card, being in Bob's library for 0/false and in Bob's hand for 1/true; this card must not have any abilities that function in those zones other than characteristic-defining abilities. There are no other cards in Bob's hand, library, or graveyard.

Wheel of Sun and Moon;.enchanting Bob allows us to set the flag to 0 by making Bob discard the card. B;Tomorrow, Azami's Familiar allows us to set the flag to 1 by making Bob draw a card, while not making Bob lose the game if the flag was already 1.

To stop Bob from playing this card, we use B;Aggressive Mining;+artifact and/or Nevermores as appropriate.

Removing other choices

Stony Silence and Cursed Totem shut off activated abilities of artifacts and creatures. Lands without other card types don't have any way to be shut off in this manner, by design, so instead, for the program permanent, we use Root Maze to make each new program permanent enter the battlefield tapped and Choke to keep them tapped (recall that they are all made Islands). Also, Bob's Sterling Grove has its activated ability shut off by Suppression Bonds attached to it.

Other stuff

AB;Recycle skips both player's draw steps. Mirror Gallery disables the "legend rule".

Both players have life total 1, and AB;Worship keeps their life totals at 1 through the damage they will be dealt. (Note that Worship only modifies the result of damage; the damage itself is still dealt, so that, for example, the Bloodthirster still triggers.)

AB;Corrosive Mentor gives wither to black creatures controlled by either player.

Instructions

0 Y Z;Add rY rZ;Add the value of rZ to the value of rY.
B;X0;Halana and Alena, Partners;=0/2;ec;+Elf;+trY

In Bob's combat phase, the Halana and Alena, Partners triggers. It targets rY, and its power is boosted by rZ to the value of rZ, thus adding that value to rY.

5 Y Z (Y≠Z);Move rY rZ;Set the value of rY to the value of rZ.
A;X5;Y*;Archpriest of Iona;+trY|A;X5;Y*;Shape Stealer;=3/3;ec;fly;=green,black;-1/-0|B;X5;Halana and Alena, Partners;=0/2;ec;+Elf;+trY

This instruction is implemented similarly to the previous one, except that we need to erase the previous value of rY before adding the value of rZ.

To do this, Alice will have a full party details needed?, so that Archpriest of Iona triggers and gives rY flying and +1/+1 in the third combat phase. The Shape Stealer attacks and is blocked by the register, taking the register's power as its base power, and the extra 1 is subtracted off, so that its power equals the register's value. It is given wither because it is black, so the damage is dealt as -1/-1 counters, cancelling out all the +1/+1 counters on the register.

In Bob's combat phase, Halana and Alena, Partners adds rZ +1/+1 counters to rY. (Note that despite having reach, this couldn't block the Shape Stealer because of the trY types, as protection also restricts blocking.)

5 Y Y;Zero rY;Set the value of rY to zero.

When Y and Z are the same, something different happens. Because the register's value is erased first, it isn't there to get added in Bob's combat phase, leaving it with no +1/+1 counters.

1 Y Z (Y≠Z);SubCond rZ rY;Subtract the value of rY from the value of rZ if that does not make it negative. Set the flag to 1 if the subtraction would have produced a negative result, 0 otherwise.
A;X1;Necrogen Mists|B;X1;Halfdane;=1/1;+trY;ec;iw|u;A;Tanuki Transplanter|B;X1;Furtive Homunculus;=0/1;+Elf;+Dragon;+tR;ec;fly;draw;=green,black|A;X1;Omnath, Locus of Mana;=0/1;ec;reach;ind|B;X1;Wrathful Red Dragon;down;+trZ|B;X1;Belligerent Brontodon

In Bob's upkeep, Necrogen Mists makes Bob discard the flag card if it's in hand, and Halfdane triggers and targets rY, taking on its power and toughness.

In Bob's combat phase, Halfdane and Furtive Homunculus attack, and Tanuki Transplanter triggers, giving Alice rY's value in green mana, which makes that the power of Omnath, Locus of Mana.

The Furtive Homunculus, with rZ power and skulk, is blocked by Omnath, Locus of Mana if rY≤rZ. If it blocks, it deals rY damage to the Furtive Homunculus, triggering Wrathful Red Dragon to make the Furtive Homunculus deal rY damage with wither to rZ, reducing its value by rY; the combat damage from the Furtive Homunculus to Omnath, Locus of Mana is prevented because of the former's tR type. If it doesn't block, Belligerent Brontodon ensures that the Furtive Homunculus deals at least 1 damage to Alice even if rZ=0, triggering the added ability to make Bob draw a card and set the flag to 1.

The green mana disappears at the end of Alice's untap step in the next turn, when Omnath, Locus of Mana is no longer active.

1 Z Z;Sub1Cond rZ;Subtract 1 from the value of rZ if that does not make it negative. Set the flag to 1 if the subtraction would have produced a negative result, 0 otherwise.
B;X1;Riders of Gavony;=X1;ec;*Rabbit;:Yeti;ts1

Riders of Gavony gives protection fron Yetis to all the registers, but only rZ gets to keep it. If Y=Z, this leaves the Halfdane with no legal targets for its ability, and its power remains 1, making 1 the value to be subtracted.

6 Y Z;Mult rZ rY;Multiply the value of rZ by the value of rY.
A;X6;Y*;Archpriest of Iona;+trY|A;X6;Y*;Smog Elemental;ind;=2/2|A;X6;Wrathful Red Dragon;=tU;ec;down;*Elemental|B;X6;Hornet Nest;ind;=blue;*Elf|B;X6;Phantom Steed;=1/1;ec;iw;*Elf|exiled;War Elemental|A;X6;Tocatli Honor Guard;=0/1;ec;ind;=red,blue,black;+Dragon|X6;Ward Sliver;*Elemental;:green|A;X6;Wrathful Red Dragon;=trZ;ec;down|B;X6;Resourceful Defense;+trZ;=green,blue

In Alice's third combat phase; Archpriest of Iona triggers and gives rY flying and +1/+1; the +1/+1 gets cancelled out by the -1/-1 from Smog Elemental.

The Smog Elemental attacks and gets blocked by rY. It receives the value of rY in damage. This triggers the first Wrathful Red Dragon to make it deal the same amount of damage to the Hornet Nest, which produces rY 1/1 green Elf creature tokens with flying and deathtouch. Affected by the Smog Elemental and rZ, their power and toughness are equal to rZ's value. (If that's 0, they die immediately.)

In Bob's combat phase, those Elf tokens attack, along with the Phantom Steed, which creates an attacking Elf token copy of War Elemental; Tocatli Honor Guard suppresses its enters-the-battlefield trigger. That token is given protection from green by the Ward Sliver, so the Tocatli Honor Guard is the only creature that can block it, and does so; the protection also stops it from being targeted later.

In the combat damage step, the War Elemental token deals rZ+1 damage to the Tocatli Honor Guard, triggering the second Wrathful Red Dragon to make it deal the same amount of damage with wither to rZ, which leaves it with one -1/-1 counter; the Elf tokens are reduced to 0 toughness and die. The Phantom Steed and the Elf tokens deal their damage to Alice, triggering the War Elemental to get rY×rZ+1 +1/+1 counters.

At the end of combat, the War Elemental token is sacrificed, triggering Resourceful Defense, which targets rZ (being blue stops it from targeting Bob's Sterling Grove) to put rY×rZ+1 +1/+1 counters on it; one gets cancelled out and its new value is rY×rZ.

8 Y Z;Store rZ rY;Store the value of rY at memory address rZ.
B;X8;Halfdane;iw;+trY;trample|X8;Godhead of Awe;down;ts0|B;X8;Wandering Wolf;+Elf;ec;fly;ind|B;X8;Behind the Scenes|B;X8;Spinneret Sliver;=X8;ec;*Mouse|B;X8;Quartzwood Crasher;*Mouse|B;X8;Arwen, Weaver of Hope;=2/2|A;X8;Aether Flash;=green,black|u;A;Charisma

A nonzero value V at a memory address A is represented by a V/V Mouse token with A +1/+1 counters on it under Alice's control. A zero value is represented by an absence of such a token.

In Bob's upkeep, Halfdane targets rY and takes on its power and toughness. (Note that the Godhead of Awe has an early timestamp of ⓪, so it doesn't affect the final power and toughness of the registers, which have their base power and toughness set at ① and possibly later.)

In Bob's combat phase, the Halfdane and Wandering Wolf attack. The Wandering Wolf has rZ+1 power, and its own ability plus skulk from Behind the Scenes together mean that it can be blocked only by creatures with exactly the same power; thus, the existing memory token for address rZ blocks if it exists (given reach by Spinneret Sliver).

Combat damage is dealt; the blocking memory token (if present) is dealt exactly enough damage to be destroyed. Halfdane deals rY damage to Alice and triggers Quartzwood Crasher if that's nonzero, which produces a Mouse creature token with that power and toughness. Arwen, Weaver of Hope (which is naturally an Elf) adds rZ+2 +1/+1 counters to it. Aether Flash triggers and deals 2 damage with wither to the token, cancelling out the extra 2 +1/+1 counters and triggering Charisma to give Alice control of it.

9 Y Z;Load rY rZ;Load the value at memory address rZ into rY.
B;X9;Archpriest of Iona;+trY|B;X9;Dream Fighter;fly;+Sliver;+tR|B;X9;Wandering Wolf;fly;ind;+Elf;+Dragon;=2/2|u;B;Skeleton Key|A;X9;Godhead of Awe;down;reach;ts0;+Sliver|A;X9;Shape Stealer;reach;+tR;=green,black;-1/-0|B;X9;Spinneret Sliver;=X9;ec;*Mouse|B;X9;Serpent of Yawning Depths;=X9;ec;*Rabbit,tR|B;X9;Field Marshal;*Mouse|A;X9;Questing Beast|B;X9;Vigor;=1/1 Elf;ec;ind;=blue|B;X9;Wrathful Red Dragon;=tU;ec;down|A;X9;Toralf, God of Fury;+trY|A;X9;Gideon's Intervention;:Wandering Wolf

In Bob's combat phase, the Archpriest of Iona gives +1/+1 and flying to rY. That register attacks, along with the Dream Fighter and the Wandering Wolf. (The Dream Fighter has been given the type tR to stop it from blocking the creatures of the conditional mechanism in Alice's turn.)

In the declare blockers step, the Godhead of Awe blocks the Dream Fighter, because those are given shadow by the Shadow Sliver. The Shape Stealer blocks rY; it can only block red creatures because of its tR type, and it is the only creature that can block rY because of the Serpent of Yawning Depths. Finally, the Wandering Wolf, because of its own ability and skulk from Skeleton Key, can only be blocked by creatures with exactly the same power. Its power is rZ+2, and each memory token (given reach by Spinneret Sliver, and affected by Godhead of Awe and Field Marshal) has power equal to 2 plus its address, so the one with address rZ blocks if it exists.

This blocking triggers two abilities: the Shape Stealer takes on rY's power as its base power, ending up with rY's value as its power, and the Dream Fighter phases out itself and the Godhead of Awe, which, most importantly, uncovers the original base power and toughness of the memory tokens.

The blocking memory token (if it exists), given first strike and +1/+1 by Field Marshal, deals its damage first, dealing address+value+1 damage to the Wandering Wolf; Questing Beast stops Vigor from preventing this damage. Wrathful Red Dragon triggers and targets Vigor, making Wandering Wolf deal the same amount of damage to it (it does not prevent damage to itself). The Vigor's toughness is rZ+1, so this triggers Toralf, God of Fury to deal the value in damage to rY; this damage is prevented by Vigor, adding the value in +1/+1 counters to rY.

In the regular combat damage step, the Shape Stealer deals its damage with wither to rY (again, Questing Beast stops Vigor from preventing it), subtracting off its original value and leaving just the memory value. Gideon's Intervention prevents the damage from Wandering Wolf, stopping it from killing the memory token or triggering the Skeleton Key's second ability.

2 Y 1;BInput rY;Set rY to a nonnegative integer of Bob's choice.
A;X2;Y*;Archpriest of Iona;+trY|A;X2;Y*;Shape Stealer;=3/3;ec;fly;=green,black;-1/-0|A;X2;Questing Beast;=0/4;ec;reach;ind;+Dragon|A;X2;Wrathful Red Dragon;down;=blue;+trY|B;X2;Vigor|B;X2;Z1;Volcano Hellion;copy;=tU;=0/0 +artifact;ec;11c

We start by clearing the value of rY, in a way we've seen before, by giving it flying and having it block a Shape Stealer; Questing Beast stops Vigor from preventing the damage. This part is shared between multiple instructions that start with card 2.

In Bob's upkeep, the Volcano Hellion produces a copy of itself, which dies immediately and targets the Wrathful Red Dragon with its ability. Bob gets to choose how much damage it deals to him and to the Wrathful Red Dragon, which triggers (if the amount is nonzero) and targets rY; that damage is turned into +1/+1 counters by Vigor.

(The unpreventability of Volcano Hellion's damage is the reason for the indirection through the Wrathful Red Dragon. However, unpreventability doesn't stop Worship from modifying the result of the damage dealt to Bob.)

2 Y 0;AInput rY;Set rY to a nonnegative integer of Alice's choice.
A;X2;Z0;Volcano Hellion;=tU;=0/0 +artifact;ec;11c;=red;+Dragon|A;X2;Z0;Artificer Class;+tR;.level 3

This is similar to the previous instruction, but it's a little more complicated because Alice's upkeep is not usable. This time, Artificer Class is used to make the copy of Volcano Hellion in Alice's end step, and the rest proceeds similarly to before; the "isn't a Dragon" targeting criterion of Wrathful Red Dragon stops it from targeting this Volcano Hellion.

2 Y 2;SetF rY;Set rY to the flag's value.
B;X2;Z2;Syr Elenora, the Discerning;fly

Syr Elenora, the Discerning attacks and gets blocked by the Questing Beast. If the flag is 1, it deals 1 damage and triggers the Wrathful Red Dragon, which adds 1 to rY as before.

2 Y 3;SetNF rY;Set rY to the Boolean negation of the flag's value (1 if it's 0 and vice versa).
B;X2;Z3;Slithering Shade;=1/1;ec

The Slithering Shade attacks if the flag is 0, making rY 1 as before.

2 Y 4;Rand6 rY;Set rY to a uniformly random nonnegative integer less than 6.
B;X2;Z4;Suntail Hawk;=-1/1;ec|u;Strength-Testing Hammer

The Suntail Hawk attacks, and the Strength-Testing Hammer triggers and increases its power to the required random number. Vigor's 6 power ensures that the "draw a card" effect never happens.

2 Y 5;Rand20 rY;Set rY to a uniformly random nonnegative integer less than 20.
B;X2;Z5;Ancient Gold Dragon;=X2;ec;iw;*Sand;first strike|B;X2;Z5;Rat Colony;=X2;=-1/1;ec;fly;*Sand|B;X2;Z5;Goblin Pyromancer;=X2;ec;*Sand

The Ancient Gold Dragon and Rat Colony attack, and the Rat Colony is blocked by the Questing Beast. The Ancient Gold Dragon first deals its damage to Alice and randomly produces 1–20 Sand tokens, which increase the Rat Colony's power to the required random number, and it then deals its damage, which goes into rY's value as before. In Bob's end step, Goblin Pyromancer gets rid of the Sand tokens. (It also triggered in Alice's end step, but did nothing.)

4 0 0;HaltD;End the game in a draw.
B;X4;Y0;Celestial Convergence;#!1

Celestial Convergence triggers in Bob's upkeep, removes its last omen counter, and compares life totals. Both players' life totals are 1, so the game ends in a draw.

4 0 1;HaltA;End the game with Alice winning.
A;X4;Y0;Z1;Alert Heedbonder

Alert Heedbonder triggers in Alice's end step and Alice gains 1 life from it counting itself, and then Alice wins from the Celestial Convergence trigger.

4 0 2;HaltB;End the game with Bob winning.
A;X4;Y0;Z2;Spiritual Sanctuary;*Forest

Spiritual Sanctuary triggers in Bob's upkeep; APNAP order means that trigger goes on top of the Celestial Convergence trigger, and resolves first. Bob does control a Forest, so Bob gains 1 life, and wins from the Celestial Convergence trigger.

4 1 Z;Add1 rZ;Add 1 to the value of rZ.
B;X4;Y1;Halana and Alena, Partners;=1/1;+trZ;ec

Halana and Alena, Partners targets rZ and adds one +1/+1 counter to it.

4 2 Z;Halve rZ;Halve the value of rZ, rounding down. Set the flag to the remainder from the division.
A;X4;Y2;Abyssal Specter;=1/1;ec;first strike|A;X4;Y2;Catacomb Dragon;=2/2;+tR;ec;=green,black|B;X4;Y2;Taii Wakeen, Perfect Shot;=0/1;+Elf;ec;reach;ind;=blue|A;X4;Y2;Wrathful Red Dragon;down;+trZ|B;X4;Y2;Wrathful Red Dragon;=tU;ec;down;*Rabbit

In Alice's third combat phase, the Catacomb Dragon and Abyssal Specter attack, in addition to the conditional mechanism's creatures. The Catacomb Dragon is blocked by Taii Wakeen, Perfect Shot.

By APNAP order, the trigger from Bob's Dream Fighter in the conditional mechanism is put on top of the Catacomb Dragon's trigger on the stack, and thus resolves first; therefore, by the time the Catacomb Dragon's trigger resolves, rZ is active and is adding its value to the power and toughness of Taii Wakeen, Perfect Shot.

Let's say the value is V. The Catacomb Dragon subtracts ⌊V/2⌋ from Taii Wakeen, Perfect Shot's power, leaving V−⌊V/2⌋ = ⌈V/2⌉ power.

In the first combat damage step, the Abyssal Specter deals 1 damage to Bob and triggers to make Bob discard a card, setting the flag to 0.

In the second combat damage step, the Catacomb Dragon's damage is prevented because of its tR type, and Taii Wakeen, Perfect Shot deals ⌈V/2⌉ damage. That damage triggers Alice's Wrathful Red Dragon, which targets rZ and makes Catacomb Dragon deal ⌈V/2⌉ damage to it with wither, reducing its value to V−⌈V/2⌉ = ⌊V/2⌋.

That damage, in turn, triggers Bob's Wrathful Red Dragon, which targets Taii Wakeen, Perfect Shot and makes rY deal ⌈V/2⌉ damage to it. This damage is checked against its current toughness of ⌊V/2⌋+1 (but does not destroy it because it has indestructible). If V is odd, the values are equal, triggering Taii Wakeen, Perfect Shot to make Bob draw a card, which sets the flag to 1.

4 3 Z;Output rZ;Output the value of rZ.
A;X4;Y3;Territorial Scythecat;=0/1;ec;fly|A;X4;Y3;Quartzwood Crasher;*Octopus|A;X4;Y3;Gruul Ragebeast;+trZ;ec|A;X4;Y3;Vigor

An output instruction is not strictly necessary, because all the calculations that a program performs are naturally visible to both players. However, it can be useful to specifically record certain values.

In Alice's third combat phase, Territorial Scythecat attacks. Its ability triggers when the third program permanent for the instruction is put onto the battlefield, giving it a +1/+1 counter. It deals 1 damage to Bob, triggering Quartzwood Crasher to make a 1/1 Octopus token, which triggers Gruul Ragebeast, which targets rZ and makes the token fight rZ. Vigor turns the damage from rZ into +1/+1 counters, which record the register's value.

If multiple Output instructions are executed, the +1/+1 counters accumulate on Territorial Scythecat, so the second Output instruction makes a 2/2 Octopus token, the third a 3/3, and so on, to indicate the order of the output values.

10 Y Z;NumBuild (12Y+Z);Set r0 to 12Y+Z, except if the last instruction that was executed was also a NumBuild instruction, in which case multiply r0 by 144 and add 12Y+Z to it.
A;X10;X*;Excruciator;fly;ind;vigilance|A;X10;Dream Fighter;=2/2;ec;fly;=blue;pro.-red|B;X10;Vigor;reach;iw;+tU|B;X10;Khorvath Brightflame;down;*Rhino|B;X10;Sylvia Brightspear;*Rhino|A;X10;Mangara's Equity;ec;*green;:red;=green,black|A;X10;Y0;Darksteel Myr;=0/1;+Nomad;ec;reach|A;X10;Y1;Darksteel Myr;=12/1;+Nomad;ec;reach|A;X10;Y2;Darksteel Myr;=24/1;+Nomad;ec;reach|...|A;X10;Y11;Darksteel Myr;=132/1;+Nomad;ec;reach|Z1;Kangee, Aerie Keeper;down;*Nomad;#1|Z2;Kangee, Aerie Keeper;down;*Nomad;#2|Z3;Kangee, Aerie Keeper;down;*Nomad;#3|...|Z11;Kangee, Aerie Keeper;down;*Nomad;#11|B;X10;Z*;Angrath's Marauders

As its name suggests, this instruction can be used repeatedly to build any nonnegative integer value in r0, two base-12 digits at a time.

In Alice's second combat phase, Excruciator and Dream Fighter attack. Vigor blocks Dream Fighter (its tU type stops it from blocking Excruciator), which triggers to phase both out; r0, given flying (and haste) by Khorvath Brightflame and double strike by Sylvia Brightspear, blocks Excruciator (Dream Fighter's protection from red stops r0 from blocking it). In the first combat damage step, r0 deals its value in damage, triggering Mangara's Equity to deal the same amount of damage back to it with wither, resetting its value to 0. r0 then deals no damage in the second combat damage step.

In Alice's third combat phase, Excruciator attacks again and is again blocked by r0. r0's value remains 0.

In Bob's untap step, Vigor phases back in. In Bob's combat phase, r0 and Vigor attack. r0 gets blocked by whichever of the twelve Darksteel Myr is active, depending on the value of Y; that one has base power 12Y. For each nonzero value of Z, a different Kangee, Aerie Keeper adds the value of Z to the power and toughness of Nomads, which includes the Darksteel Myr, so that its power is 12Y+Z, which gets added to r0's value because of Vigor. Note that these Kangee, Aerie Keepers are not conditional on anything other than Z; they will also be used by some other instructions.

If another NumBuild instruction is executed next, Bob's Vigor will still be tapped, and thus will be unable to block Dream Fighter, and will still be phased in to prevent the damage from Mangara's Equity to r0; however, Excruciator's damage can't be prevented. Instead of r0's value being reset to 0, it will be doubled twice, from V to 4V. In Alice's third combat phase, Angrath's Marauders doubles the damage dealt by r0, so its value gets tripled in each of the combat damage steps, going from 4V to 36V. Finally, in Bob's combat phase, the value gets doubled twice and gets 12Y+Z added, going from 36V to 144V+12Y+Z.

3 0 Z (Z≠0);JumpFwd Z;Jump forward by Z instructions (=3Z cards).
B;X3;Fiery Emancipation;=0/1;+Dragon;+Nomad;ec;fly;ind;=blue,black;first strike|B;X3;Chains of Mephistopheles;=0/1;+Sliver;ec;fly;+artifact;=green,black|u;A;Moonsilver Spear;*Scarecrow|A;X3;Reaper King;+tR;+tU;=green,blue,red|A;X3;Spellbane Centaur;*red|X3;Y0;Shadow Sliver;*Dragon|A;X3;Melira's Keepers;=0/1;+Sliver;+tU;ec;reach;ind;lifelink|u;Spiteful Shadows|A;X3;Empyrial Archangel;ind;down;+Dragon;=green,black|A;X3;Lich

Recall that the program is a cyclic sequence of cards. To advance through the program, we need to rotate that sequence. The first obstacle is that the sequence isn't all in one place: one of the cards is on the battlefield, while the rest are in Alice's library. Let's fix that.

In Bob's combat phase, Fiery Emancipation and Chains of Mephistopheles attack, triggering Moonsilver Spear. Alice creates a 4/4 white Scarecrow token with flying. It triggers Reaper King, which targets the program permanent; being blue stops it from targeting Bob's Sterling Grove, and Spellbane Centaur stops it from targeting the Scarecrow token. This destroys the program permanent, sending it to the bottom of Alice's library (because of Wheel of Sun and Moon). Next turn, the Scarecrow token will be Alice's target for the Vaevictis Asmadi, the Dire that advances the program (because it isn't green, red, or blue), in place of the program permanent. (It will also attack at the same time, but is then sacrificed.)

Now that the program is all in Alice's library, we can rotate it by milling that library – but only one card at a time, otherwise Alice will get to choose the order in which the cards are placed at the bottom of the library. We will do this by making Alice draw cards – the rules force this to be done one at a time – and then using Chains of Mephistopheles to replace each card draw with a 1-card mill.

The Fiery Emancipation is given shadow by the Shadow Sliver, so the Melira's Keepers (which also has shadow) blocks it; the tU type stops it from blocking the Chains of Mephistopheles.

The Fiery Emancipation has power Z (because it's a Nomad), and triples its own damage to 3Z. This damage is dealt with wither, but the ability of the Melira's Keepers stops it from getting -1/-1 counters (but the damage itself is still dealt). The damage triggers Spiteful Shadows, which makes the Melira's Keepers deal 3Z damage to Alice, which the Empyrial Archangel redirects to itself. This damage is dealt with lifelink, and Alice's Lich replaces the life gain with drawing cards; Chains of Mephistopheles replaces each card draw with a 1-card mill, advancing 3Z cards through the program.

(Setup note: The ability counters on the Melira's Keepers were placed while its abilities were removed by Blood Sun.)

3 0 0;JumpFwd r0;Jump forward by r0 instructions (=3×r0 cards).
B;X3;Z0;Akron Legionnaire;=0/1;+Dragon;+Elf;ec;fly;ind;=blue,black;first strike

When Z=0, the Akron Legionnaire stops the Fiery Emancipation from attacking, and it attacks instead. It is given similar characteristics, but has the creature type Elf instead of Nomad, thus having power r0, which is used as the jump distance instead of Z.

3 1 Z;JumpBwd Z′;Jump backward by Z′ instructions (=3Z′ cards).
As with the previous instruction, if Z=0, Z′ is r0, and otherwise, Z′ is Z.
Backward jumps by more than P cards do nothing. P is usually equal to the length of the program in cards; it is the first multiple of the length that is at least 6.
A;X3;Joraga Warcaller;#P-5;*Scarecrow|A;X3;Justice;*white;lifelink|A;X3;Rotlung Reanimator;*Scarecrow~white Sand

In Bob's combat phase, the attacking creatures are the same as before. However, because the Shadow Sliver is not active, the attacking Fiery Emancipation or Akron Legionnaire is not given shadow. Instead of being blocked by the Melira's Keepers, it is blocked by the Scarecrow token (which has flying).

In the first combat damage step, the Fiery Emancipation or Akron Legionnaire deals 3Z′ damage with wither to the Scarecrow token. Its power was P (base 4, then boosted by Reaper King and Joraga Warcaller), which is reduced to P−3Z′.

In the second combat damage step, the Scarecrow token deals P−3Z′ damage to the creature it is blocking. Justice triggers from that damage, dealing the same amount of damage, redirected to the Empyrial Archangel, with lifelink. As before, Lich replaces the life gain, and Chains of Mephistopheles replaces each card draw, to advance P−3Z cards through the program.

If the jump distance exceeds P, the Scarecrow token is killed. Rotlung Reanimator triggers, making a white Sand token in its place as the target for Vaevictis Asmadi, the Dire next turn.

3 2 Z;JumpFwdNF Z′;Jump forward by Z′ instructions (=3Z′ cards) if the flag is 0/false.
3 3 Z;JumpBwdNF Z′;Jump backward by Z′ instructions (=3Z′ cards) if the flag is 0/false.
A;X3;Y2;Blinding Angel;=1/1;ec|A;X3;Y3;Blinding Angel;=1/1;ec|B;X3;Y*;Meishin, the Mind Cage;=0/3;ec;reach|X3;Y2;Shadow Sliver;*Dragon

In Alice's third combat phase, a Blinding Angel attacks. If the flag is 0, it deals 1 damage to Bob and triggers its ability to skip Bob's combat phase, so no jump takes place. If the flag is 1, Meishin, the Mind Cage reduces its power to 0 and it deals no damage, and the jump takes place as before.

3 4 Z;JumpFwdF Z′;Jump forward by Z′ instructions (=3Z′ cards) if the flag is 1/true.
3 5 Z;JumpBwdF Z′;Jump backward by Z′ instructions (=3Z′ cards) if the flag is 1/true.
A;X3;Y4;Blinding Angel;=2/2;ec;pro.-black|A;X3;Y5;Blinding Angel;=2/2;ec;pro.-black|X3;Y4;Shadow Sliver;*Dragon

Again, in Alice's third combat phase, a Blinding Angel attacks. This time, if the flag is 1, it is 1/2 and deals 1 damage to Bob and triggers its ability to skip Bob's combat phase, whereas if the flag is 0, it's 2/2 and is not made unblockable by Alice's Tetsuko Umezawa, Fugitive, and Meishin, the Mind Cage blocks it (protection from black stops anything else from blocking it).

3 6 0;CallFwd r0;Call a function r0 instructions ahead: Jump forward 3×r0 cards and push P−3×r0 onto the return stack. If r0=0 or 3×r0>P, this is undefined behaviour.
B;X3;Y6;Oubliette;copy;=artifact;+creature;=blue Starfish;+tU;+X3;+Y6;=3/4;ec;=green|B;X3;Y6;Spellbane Centaur|B;X3;Y6;Arwen, Weaver of Hope;=1/1 X3;ec;.P−1 +1/+1 counters|A;X3;Y6;Z0;Shadow Sliver;*Dragon|A;X3;Y6;Wrathful Red Dragon;down;+tU|A;X3;Y6;Willbreaker|.|.Initial return stack|A;Oubliette;=artifact;+creature;=blue Starfish;+tU;+X3;+Y6;=3/4;ec|A;Celestial Convergence;#!1;.phased out by the above

(Note that unlike the other jump instructions, call instructions use only r0 for the distance, and not the value of Z. This is because it is less common for calls to have a short distance.)

The return stack is made up of Oubliette creature tokens under Alice's control. Each one phases out the previous one, so that only the top one is phased in.

In Bob's upkeep, Bob gets a token copy of Oubliette, and Arwen, Weaver of Hope adds P +1/+1 counters to it. Its ability targets the previous top-of-stack token and phases it out; Spellbane Centaur stops it from targeting itself or Bob's other blue creatures.

We continue in the same way as a JumpFwd r0 instruction, which ends with damage dealt with lifelink to Empyrial Archangel, with the life gain replaced by Lich and Chains of Mephistopheles to advance through the program.

This time, that damage also triggers Wrathful Red Dragon, which targets the new Oubliette token; the "isn't a Dragon" targeting criterion stops it from targeting Bob's other blue creatures. Willbreaker triggers, and Alice gains control of the Oubliette token. Then the Wrathful Red Dragon trigger resolves, making Empyrial Archangel deal 3×r0 damage with wither to the Oubliette token, reducing the number of +1/+1 counters on it to P−3×r0. (Its power is 3 higher than the value pushed onto the return stack, for reasons to be seen later.)

3 7 Z;Return Z′;Return from a function Z′ instructions long: Pop a value S from the return stack, and jump forward max(0,S−3Z′) cards. If the return stack was empty, end the game in a draw.
X3;Y7;Razorjaw Oni;*white|X3;Y7;Spinneret Sliver;=X3;ec;*Starfish;ts3|A;X3;Y7;Syphon Sliver;=X3;ec;*Starfish;ts3|B;X3;Y7;Sosuke, Son of Seshiro;*Dragon

You may be wondering why this instruction needs the length of the function. It's because we only have relative jumps, as there is no program counter; the program is rotated to advance through it. The call instruction used the offset between the call site and the start of the function, but to return, we need the offset between the end of the function and the call site.

We begin in the same way as a JumpBwd instruction, with a creature with Z′ power attacking. Razorjaw Oni stops the Scarecrow token from blocking. Spinneret Sliver gives reach to the top-of-stack token, timestamped later than the Blood Sun (which is currently removing that token's abilities, as it has conditional types X3 and Y6), so the top-of-stack token blocks instead. (This is why it is important that the attacking Fiery Emancipation or Akron Legionnaire is blue rather than green – the top-of-stack token has type tU, so it wouldn't be able to block otherwise.)

In the first combat damage step, the attacking Fiery Emancipation or Akron Legionnaire has 1 extra power from Sosuke, Son of Seshiro, so it deals 3Z′+3 damage with wither to the top-of-stack token, reducing its power from S+3 to S−3Z′. Sosuke, Son of Seshiro triggers to destroy it at end of combat.

In the second combat damage step, the top-of-stack token deals its power in damage if it is still alive. It is given lifelink by Syphon Sliver, and the life gain is replaced by Lich and Chains of Mephistopheles to advance through the program.

If the stack is empty, destroying the base of the stack phases in a Celestial Convergence, which triggers in Alice's upkeep to end the game in a draw. This is a convenience feature to allow the same code to be used as a function and as a program.

3 6 1;CallBwd r0;Call a function r0 instructions behind: Jump backward 3×r0 cards and push 3×r0 onto the return stack. If 3×r0≥P, this is undefined behaviour.
X3;Y6;Dormant Sliver;*Nomad|B;X3;Y6;Skanos Dragonheart;=Nomad;=0/1;ec;fly;ind;*Rhino;+Dragon;=blue,black;first strike

As with the CallFwd instruction, in Bob's upkeep, Bob gets a token copy of Oubliette, whose ability targets the previous top-of-stack token and phases it out.

Dormant Sliver stops the Fiery Emancipation from attacking, and Skanos Dragonheart attacks instead. It is given similar characteristics, and its ability triggers, adding the value of r0 to its power.

We proceed in the same way as a JumpBwd instruction, up to the Justice dealing P−3Z′ damage with lifelink to the Empyrial Archangel. Then, in the same way as the CallFwd instruction, Wrathful Red Dragon triggers from that damage, and the same sequence of events follows, to give Alice control of the new top-of-stack token and adjust its power.

(Skanos Dragonheart doesn't interfere with the CallFwd instruction because Akron Legionnaire also stops it from attacking when Z=0.)

3 6 2;CallBwdR r0;Call a function r0 instructions behind (direct-recursion-capable): Jump backward 3×r0 cards and push P+3×r0 onto the return stack. If 3×r0≥P, this is undefined behaviour.
B;X3;Y6;Z2;Corpsejack Menace

This variant instruction is necessary when a function calls itself directly: if the regular CallBwd instruction is used to do that, the value pushed onto the return stack is the distance between the start of the function and the call site, and on returning, subtracting the length of the function yields a negative value, which results in no jump, which is incorrect.

Corpsejack Menace doubles the number of +1/+1 counters on the new Oubliette token to 2P, and the rest is as before.

11 Y Z (Y≠Z);FLess rZ rY;Set the flag to 1 if rZ<rY, 0 otherwise. Flag-combining.
A;X11;Necrogen Mists|B;X11;Halfdane;=1/1;+trY;ec;fly;+1/+0|B;X11;Okk;=1/1 Elf;ec;fly;draw|B;X11;Bishop of Binding;=1/1 X11;ec;*Fractal|A;Tamiyo, Collector of Tales;=artifact;+creature +Fractal;ec|B;X11;Willbreaker;+Mountain|X2;Y2;Shimmer;:Mountain|X2;Y3;Shimmer;:Mountain|X3;Shimmer;:Mountain

In Bob's upkeep, Necrogen Mists makes Bob discard the flag card if it's in hand, and Halfdane triggers and targets rY, taking its power and toughness as base power and toughness; its power is now Y+1.

In Bob's combat phase, Halfdane attacks; Okk has Z+1 power, so can attack only if Y>Z. If so, it deals its damage to Alice and triggers the added ability to draw a card, which sets the flag to 1.

Flag-combining is a property used by several instructions whose only purpose is to set the flag. It means that flag values given by subsequent instructions are combined by logical OR instead of replacing the flag's value. This state ends when any of the following is executed:

For example, this can be used to check whether r0 and r1 are equal, with FLess r0 r1 followed by FLess r1 r0.

To accomplish this, Bishop of Binding also attacks; its power is 1, never high enough for it to let Okk attack. Its ability targets Tamiyo, Collector of Tales (which has been made a creature and not a planeswalker), triggering Willbreaker to make Bob gain control of Tamiyo, Collector of Tales. While under Bob's control, it stops Bob from being made to discard the flag card by abilities Alice controls, so the flag remains 1 if it is 1.

This Willbreaker has Mountain added to its types (which only works while Life and Limb makes it a land). For instructions that end the flag-combining state, Shimmer makes it phase out in Bob's untap step if it wasn't already phased out, which returns control of Tamiyo, Collector of Tales to Alice.

11 Z Z;FIsZero rZ;Set the flag to 1 if rZ=0, 0 otherwise. Flag-combining.
B;X11;Riders of Gavony;=X11;ec;*Rabbit;:Yeti;ts1

As with Sub1Cond, Riders of Gavony gives protection from Yetis to all the registers, but only rZ gets to keep it. If Y=Z, this leaves the Halfdane with no legal targets for its ability, and its base power remains 1, making 1 the value to be compared with.

4 6 Z;Divide rZ;Divide rZ by r0. Set rZ to the remainder and r6 to the quotient. Set the flag to 1 if the remainder is nonzero, 0 if it is zero. If r0=0, Z=0, or Z=6, this is undefined behaviour.
A;X4;Y6;Y*;Vigor;+Dragon;+Horror;ec;slime;iw;ind |u;Invisibility;*Rhino |B;X4;Y6;Questing Beast |A;X4;Y6;Wandering Wolf;=-3/4;ec;fly;ind;=blue,black;vigilance |u;Predatory Impetus |A;X4;Y6;Joraga Warcaller;=0/1;ec;ind;+artifact;=green,blue;vigilance;first strike;deathtouch;#1 |u;A;Pollenbright Wings;*Sand |A;X4;Y6;Idris, Soul of the TARDIS;+Elf;=-6/6;ec;fly;pro.-red |exiled;Bloodthirster |X4;Y6;Talon Sliver;=X4;ec;*Rhino |A;X4;Y6;Z*;Wrathful Red Dragon;+tU;ec;down |B;X4;Y6;Y*;Sludge Monster;fly;=red Elf;=0/1;ec;ts4 |B;X4;Y6;Z*;Melira, Sylvok Outcast;+Horror;ec;slime |B;X4;Y6;Z*;Mangara's Equity;*blue,blue,red;=green,black;:blue |B;X4;Y6;Z*;Martyrs of Korlis;+Horror;ec;slime;ind;=green,red |A;X4;Y6;Z*;Sludge Monster;+Bat;+Dragon;ec;slime;*Bat |X4;Y6;Z*;Ghosts of the Innocent;+Bat;+Dragon;ec;slime |AB;X4;Y6;Z*;Clamavus;+Bat;+Dragon;ec;slime |X4;Y6;Z*;Spinneret Sliver;=Bat;+Dragon;ec;slime;*Rabbit |B;X4;Y6;Sludge Monster;copy;fly;=red Elf;+X4;+Y6;+Y*;=0/1;ec;down;=X4;+Y6;*X4 |A;X4;Y6;Necrogen Mists |B;X4;Y6;Quartzwood Crasher;=X4;=3/3;ec;iw;*Sand;first strike |B;X4;Y6;Shape Stealer;+Dragon;ec;slime;fly;=green,black;pro.-green;first strike |B;X4;Y6;Tyrannical Pitlord;+Dragon;ec;slime;down;ts3;:r6 |B;X4;Y6;Deepchannel Mentor;+Elf;=0/1;ec;iw;*red;draw |A;X4;Y6;Mangara's Equity;=green,black;:red |B;X4;Y6;Goblin Pyromancer;=Dragon;ec;slime;*Sand |X4;Y6;Sliver Legion;=X4;ec;*Sand |B;X4;Y6;Death's Presence;+trY;+Dragon;ec;slime

This instruction performs long division in binary. First, it goes up through the powers of 2 to determine where to start the long division. Next, it goes down through the powers of 2, subtracting the divisor times the power of 2 from the dividend if possible (without making it negative), and producing a 1 bit in the quotient each time the subtraction is performed (and a 0 bit otherwise).

In Alice's third combat phase, in addition to the conditional mechanism's creatures, Alice's Vigor, Wandering Wolf, Joraga Warcaller, and Idris, Soul of the TARDIS attack. The Vigor has islandwalk, but Bob does not control an Island; because of Invisibility, r0 is the only creature that can block it, so it does so. The other three creatures can't be blocked because of Alice's Tetsuko Umezawa, Fugitive, as their powers are 0, 1, and 1.

In the first combat damage step, Joraga Warcaller's 1 damage is redirected from Bob to Martyrs of Korlis. It triggers Mangara's Equity; Vigor prevents that damage and gives Joraga Warcaller a second +1/+1 counter.

Also in the first combat damage step, because r0 is given first strike by Talon Sliver, it deals its value in damage to Vigor, which triggers Wrathful Red Dragon, which targets Wandering Wolf. Vigor prevents the damage and gives Wandering Wolf r0 +1/+1 counters. (There is a Sludge Monster that necessarily has a late timestamp, because it will be destroyed and re-created; thus it removes all abilities, including protection, from affected creatures. However, all of those affected creatures have been made Dragons, so they are still not legal targets for this ability.)

(Setup note: For this Mangara's Equity, cast Glasspool Mimic and copy the spell with Reflections of Littjara, then apply text-changing effects to the copy with Spectral Shift. Let the spell copy resolve, and have it enter the battlefield as a copy of a Mangara's Equity that is itself copiably made a creature. This way, it enters the battlefield with the text-changing effects already in place, so that they can affect the choice of color.)

In the second combat damage step, Wandering Wolf deals its damage to Bob, and Mangara's Equity and Vigor increase its number of +1/+1 counters to 2×r0.

Also, Idris, Soul of the TARDIS deals its damage to Bob. This triggers the ability it obtains from the exiled Bloodthirster, which adds another combat phase and untaps it. (Note that it does not have the static abilities of the Bloodthirster, so it can continue to attack in later combat phases.)

The numbers of +1/+1 counters on Alice's Wandering Wolf and Joraga Warcaller will be 2k×r0 and 2k, respectively; we now have k=1.

In the next combat phase, Alice's Wandering Wolf, Joraga Warcaller, and Idris, Soul of the TARDIS attack.

Bob's Sludge Monster can block either the Wandering Wolf or the Joraga Warcaller. Because of the Predatory Impetus, having it block the Wandering Wolf fulfils two requirements. If its power, which equals rZ, is high enough (at least 2k×r0), it does so.

Similarly to before, both Wandering Wolf and Joraga Warcaller trigger Mangara's Equity with their damage, and Vigor applies, to double the number of +1/+1 counters they have, increasing k by 1. Melira, Sylvok Outcast stops the Sludge Monster from getting -1/-1 counters, and Questing Beast stops Vigor from preventing the Sludge Monster's combat damage. Also, Idris, Soul of the TARDIS adds another combat phase, and this repeats.

When 2k×r0 exceeds the value of rZ, it is no longer possible for Bob's Sludge Monster to block the Wandering Wolf. Instead, it blocks the Joraga Warcaller. In the first combat damage step, because the Joraga Warcaller has deathtouch, its damage destroys the Sludge Monster. Its removal of abilities is lifted from several creatures, including a second Sludge Monster, this one modified to affect non-Bat creatures with slime counters instead of non-Horror creatures. It now removes the abilities of Vigor, Martyrs of Korlis, and Melira, Sylvok Outcast.

Mangara's Equity triggers, as before, to deal the same amount of damage back to Joraga Warcaller. This time, Ghosts of the Innocent halves the damage, which is dealt with wither, cancelling out half of the +1/+1 counters on the Joraga Warcaller.

In the second combat damage step, the Wandering Wolf deals its damage to Bob. Because both players now have an active Clamavus, the damage is initially double the number of +1/+1 counters it has, before Ghosts of the Innocent halves it to just the number of +1/+1 counters. Mangara's Equity triggers, and its damage is also halved, cancelling out half of the +1/+1 counters on the Wandering Wolf. The value of k is now decreasing by 1 each combat phase instead of increasing.

We proceed to more combat phases, still with Wandering Wolf, Joraga Warcaller, and Idris, Soul of the TARDIS attacking. Now, instead of Bob's Sludge Monster, rZ is available to block because of Spinneret Sliver.

If rZ ≥ 2k×r0, rZ blocks the Wandering Wolf, which deals 2k×r0 damage with wither, subtracting that from the value of rZ. Also, the Joraga Warcaller deals 2k damage to Bob, triggering Pollenbright Wings to make Alice create that many Sand tokens. These tokens will add up to produce the quotient.

Otherwise (if rZ < 2k×r0), rZ blocks the Joraga Warcaller. In this case, the damage dealt is inconsequential, except that the value of k continues to decrease.

Finally, when k=0, Idris, Soul of the TARDIS has 1 power. Because Ghosts of the Innocent rounds down when halving damage, it deals no damage to Bob, ending the sequence of combat phases.

Proceeding to Bob's turn, a bunch of creatures are now inactive, including the second Sludge Monster. This lifts the removal of abilities from another group of creatures: those that have slime counters but are neither Horrors nor Bats.

In Bob's upkeep, a third Sludge Monster triggers to re-create the destroyed Sludge Monster token; this one is modified to affect non-X4 creatures with slime counters, which we have none of. The new Sludge Monster token is already inactive when it enters the battlefield because of its Y* type, so its ability doesn't trigger. Also, Necrogen Mists makes Bob discard the flag card if it's in hand.

In Bob's combat phase, Quartzwood Crasher, Shape Stealer, Deepchannel Mentor, and r6 (given flying by Tyrannical Pitlord) attack. Deepchannel Mentor makes r6 unblockable. Wandering Wolf blocks Shape Stealer, which takes on its power and toughness, and deals its damage in the first combat damage step, cancelling out any remaining +1/+1 counters on the Wandering Wolf. Quartzwood Crasher deals 3 damage to Alice and triggers to make a 3/3 Sand token.

If the value of rZ, which is now the remainder, is nonzero, Deepchannel Mentor deals damage to Alice and triggers to make Bob draw the flag card. r6 deals its value plus 3 (from Tyrannical Pitlord) in damage to Alice, triggering the second Mangara's Equity, which deals that much damage back to it with wither, leaving it with three -1/-1 counters.

In Bob's end step, Goblin Pyromancer triggers and destroys all Sands. Death's Presence triggers for Bob's Sand token and targets r6 (which is rY); because of Sliver Legion, the power of that Sand token is 3 plus the quotient, which gets added to r6 in +1/+1 counters, making its value equal to the quotient.