Skip to content

Instantly share code, notes, and snippets.

@samis
Created April 16, 2014 20:11
Show Gist options
  • Save samis/10928033 to your computer and use it in GitHub Desktop.
Save samis/10928033 to your computer and use it in GitHub Desktop.
"Electropuzzle" by CompanionCube
[Include Original Parser by Ron Newcomb]
Part 0 - Definitions
Electric current is a kind of value.
The specification of electric current is "Used to measure the amount of
electricity flowing through something at any given moment. It measures down to
1mA, roughly the tiniest amount of current which human skin can feel at
all, and right up to the current in a really strong lightning bolt, which
the human skin would probably not have time to feel. (Actually, 100mA or
0.1A is enough to make a fatal shock; electric eels produce about 70mA,
which humans can just about survive.)"
1A (in metric units, in A) or 1 amp (in amps, singular) or 2 amps
(in amps, plural) specifies an electric current.
1mA (in metric units, in mA) or 1 milliamp (in milliamps, singular) or
2 milliamps (in milliamps, plural) specifies an electric current scaled
down by 1000.
Elapsed time is a kind of value.
The specification of elapsed time is "Used to measure how much time something takes.
Inform already has a built-in kind of value called 'time', which counts in
minutes and keeps track of the time of day - which is fine for most stories,
but not good enough for science. So we call this more precise version
'elapsed time'. It measures down to one jiffy (0.01s), briefer than one frame
of a Hollywood movie, or up to about nine months, the time it takes for
a child to be conceived and born."
1s (in metric units, in s) or 1 second (in seconds, singular) or 2 seconds
(in seconds, plural) specifies an elapsed time scaled at 100.
1 min (in metric units, in min) specifies an elapsed time scaled up by 60.
1 hr (in metric units, in hr) specifies an elapsed time scaled up by 3600.
1 day (in metric units, in days, singular) or 2 days (in metric units,
in days, plural) specifies an elapsed time scaled up by 86400.
1 week (in metric units, in weeks, singular) or 2 weeks (in metric units,
in weeks, plural) specifies an elapsed time scaled up by 604800.
Power is a kind of value.
1W (in metric units, in W) or 1 Watt (in Watts, singular) or 2 Watts
(in Watts, plural) specifies a power.
1mW (in metric units, in mW) or 1 milliwatt (in milliwatts, singular) or 2 milliwatts
(in milliwatts, plural) specifies a power scaled down by 1000.
1kW (in metric units, in kW) or 1 kilowatt (in kilowatts, singular) or 2 kilowatts
(in kilowatts, plural) specifies a power scaled up by 1000.
The specification of power is "Used to measure how much energy something can
apply in a given time - in the same period of time powerful things can do a lot
while feeble things much less. Typical domestic light bulbs take 60W of power
to run (twice as much as the human brain), and electric heaters perhaps 3kW.
Inform measures down to the power of the tiny laser in a CD player, or up to
the power of a small aircraft or diesel train."
Electric charge is a kind of value.
1 C (in metric units, in C) or 1 Coulomb (in Coulombs, singular) or 2 Coulombs
(in Coulombs, plural) specifies an electric charge scaled at 1000.
1 kC (in metric units, in kC) or 1 kilocoulomb (in kilocoulombs, singular)
or 2 kilocoulombs (in kilocoulombs, plural) specifies an electric charge
scaled up by 1000.
The specification of electric charge is "Electricity works because,
although matter is usually 'neutral', electric charge can flow between one
thing and another so that this balance is broken, and then a force is felt
between them. Electric forces are very strong, so even a small charge has a
big effect - a storm cloud might only have a charge of 20 C, but that's
enough to cause thunder and lightning. On the other hand batteries store
very large charges, but of course release them much more slowly - a typical
car battery holds about 200 kC. (Note that Inform writes '1 C' for one
coulomb, and '1C' for one degree centigrade.)"
Elapsed time times electric current specifies an electric charge.
Voltage is a kind of value.
1V (in metric units, in V) or 1 volt (in volts, singular) or 2 volts
(in volts, plural) specifies a voltage.
1mV (in metric units, in mV) or 1 millivolt (in millivolts, singular) or 2 millivolts
(in millivolts, plural) specifies a voltage scaled down by 1000.
1kV (in metric units, in kV) or 1 kilovolt (in kilovolts, singular) or 2 kilovolts
(in kilovolts, plural) specifies a voltage scaled up by 1000.
Voltage times electric current specifies a power.
The specification of voltage is "Measures the 'potential difference'
between two points, a sort of pulling power for electricity. Inform
measures down below the voltage across a human nerve cell, and up to twice
the maximum voltage ever applied on overhead power lines carried by
electric pylons. Quite low voltages can be dangerous on human skin - a 50V
potential difference between two points on the body can cause enough charge
to flow to electrocute somebody."
Part 1 - Game
Test is a room.
A machine is a kind of device.
A machine has some text called its function.
A machine can be either electrical or mechanical.
A machine is usually electrical.
A machine can be earthed.
A machine can be powered.
A machine has a voltage called the minimum voltage.
A machine has a electric charge called the minimum charge.
A machine has a power called the power rating.
A machine has an electric current called the minimum current.
A machine is either processed or unprocessed.
ThingOMatic is a machine in Test.
ThingOMatic has minimum voltage 1V.
ThingOMatic has minimum current 1A.
This is the mechanical machines rule:
now all mechanical machines are not earthed;
now all mechanical machines are not powered.
This is the update machine physics rule:
repeat with current machine running through every electrical machine:
update electricity.
To update electricity:
say "Electrical physics updated."
The machine rules is a rulebook.
The mechanical machines rule is listed in the machine rules.
The update machine physics rule is listed in the machine rules.
Every turn:
follow the machine rules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment