Transmutations
Example 227
★Suppose we want to have a machine in our game that can transmute one item into another, similar object with different properties: a bag of jelly beans into a bag of jewels, for instance. Thus each item will be associated with some number of equivalents -- the other objects it can turn into. This is a handy use for group relations:
"Transmutations"
Workshop is a room.
Transmutation relates things to each other in groups. The verb to become means the transmutation relation.
Definition: a thing is transmutable if it becomes more than one thing. [* It always becomes itself.]
A thing can be valuable. Something valuable called a bag of jewels is carried by the player. It becomes the bag of gunpowder and the bag of jelly beans.
A thing can be dangerous. The bag of gunpowder is a dangerous thing.
The bag of jelly beans is an edible thing.
The machine is fixed in place in the workshop.
The can't insert into what's not a container rule does nothing when inserting something into the machine.
Check inserting something which is not transmutable into the machine:
instead say "You can't transmute that."
To decide which thing is new form of (obj - edible thing): decide on a random valuable thing which becomes obj.
To decide which thing is new form of (obj - dangerous thing): decide on a random edible thing which becomes obj.
To decide which thing is new form of (obj - valuable thing): decide on a random dangerous thing which becomes obj.
Carry out inserting something into the machine:
now the noun is nowhere;
now the player carries the new form of the noun;
rule succeeds.
Report inserting something edible into the machine:
say "The machine clicks, whirrs, and spits out [a new form of the noun]. You're rich!";
rule succeeds.
Report inserting something dangerous into the machine:
say "The machine clicks, whirrs, and in a shower of flavor crystals, spits out [a new form of the noun].";
rule succeeds.
Report inserting something valuable into the machine:
say "The machine clicks, whirrs, and with a violent roar, spits out [a new form of the noun].";
rule succeeds.
Test me with "i / put jewels in machine / i / put gunpowder in machine / i / put beans in machine".
Test me with "i / put jewels in machine / i / put gunpowder in machine / i / put beans in machine".
Workshop
You can see a machine here.
>(Testing.)
>[1] i
You are carrying:
a bag of jewels
>[2] put jewels in machine
The machine clicks, whirrs, and with a violent roar, spits out a bag of gunpowder.
>[3] i
You are carrying:
a bag of gunpowder
>[4] put gunpowder in machine
The machine clicks, whirrs, and in a shower of flavor crystals, spits out a bag of jelly beans.
>[5] i
You are carrying:
a bag of jelly beans
>[6] put beans in machine
The machine clicks, whirrs, and spits out a bag of jewels. You're rich!
You can see a machine here.
>(Testing.)
>[1] i
You are carrying:
a bag of jewels
>[2] put jewels in machine
The machine clicks, whirrs, and with a violent roar, spits out a bag of gunpowder.
>[3] i
You are carrying:
a bag of gunpowder
>[4] put gunpowder in machine
The machine clicks, whirrs, and in a shower of flavor crystals, spits out a bag of jelly beans.
>[5] i
You are carrying:
a bag of jelly beans
>[6] put beans in machine
The machine clicks, whirrs, and spits out a bag of jewels. You're rich!
In this example we have only defined a single set of transmutable objects, but we could easily expand to include other groups.
(Thanks to Jesse McGrew for proposing this example.)