git @ Cat's Eye Technologies REDGREEN / master src / redgreen.alp
master

Tree @master (Download .tar.gz)

redgreen.alp @masterraw · history · blame

/*
 * REDGREEN.ALP - REDGREEN description in ALPACA, v2007.0722
 * Covered under a BSD-style license; see LICENSE for more information.
 *
 * History:
 * Jul 28 1998: Original version (0.60)
 * May  3 2007: Added BSD License 
 * Jul 22 2007: fixed behaviour of Wire, Zappy, and BigZappy, thanks to
 *              bug report by Stewart Gordon.  Following the REDGREEN
 *              description in doc/redgreen.html, Wire now conforms to
 *              WireWorld rules, and Zappy and BigZappy are now Burner.
 * Oct 13 2012: fixed behaviour of Fish (a Fish surrounded on all sides
 *              by fish should not turn into air,) thanks to a patch
 *              provided by Sgeo.
 */

/*** BEGIN ***/

/*** CLASSES ***/

class Fallable
  to Air when not v is Support and 2 Air and not 1 DuctTape,
  to Water when not v is Support and 4 Water and not 1 DuctTape,
  to me when (v ConveyorLeft and not < is Passthru) or (v ConveyorRight and not > is Passthru);

class Passthru
  to ^ when ^ is Fallable,
  to > when > is Fallable and v> ConveyorLeft,
  to < when < is Fallable and v< ConveyorRight;

class Flammable
  to Fire when 1 is Burner;

class Steamy
  to Water when < Water or > Water or ^< Water or ^> Water or ^ Water,
  to Air;

class Burner;
class Support;

/*** STATES ***/

state Air " "
 is Passthru
  to Water when ^ Water or ^< Water or ^> Water
             or (< Water and v< is Support)
             or (< Water and v< Water and v Water)
             or (> Water and v> is Support)
             or (> Water and v> Water and v Water),
  to Steam when v Steam or v< Steam or v> Steam,
  to Smoke when v Smoke or v< Smoke or v> Smoke,
  to Zappy when 1 Spark;

state Water "~"
 is Passthru
  to Steam when 1 Fire or 1 Magma,
  to Bubble when v Bubble or v Smoke or v Steam,
  to Fish when 3 Fish and 5 Water;

state Fire "%"
 is Passthru
 is Burner
  to Smoke when 1 Water or not 1 Air or (not 1 Torch and not 1 DuctTape and not 1 Twig);

state Earth "#"
 is Support
  to Magma when 1 Fire;

state Magma "&"
 is Support
 is Burner
  to Earth when not 1 Fire and not 2 Magma;

state Steam "s"
 is Passthru
 is Steamy;

state Smoke "@"
 is Passthru
 is Steamy;

state Bubble "o"
 is Passthru
 is Steamy;

state Fish "f"
  to Air when not 1 Water and not 8 Fish,
  to Water when 4 Fish or 7 Water;

state OnePebble "."
 is Fallable
  to TwoPebble when ^ OnePebble and (v is Support);

state TwoPebble ":"
 is Fallable
 is Support;

state Spark "*"
 is Support
 is Burner
  to Tail;

state Tail "-"
 is Support
  to Wire;

state Wire "="
 is Support
  to Spark when 1 Spark and not 3 Spark;

state DuctTape "D"
 is Support
 is Flammable
  to UnravelTape when (not 2 DuctTape) or (not (1 DuctTape and 1 is Support));

state UnravelTape "O"
 is Fallable
 is Flammable;

state Twig "l"
 is Fallable
 is Support
 is Flammable;

state Zappy "z"
 is Passthru
 is Burner
  to BigZappy;

state BigZappy "Z"
 is Passthru
 is Burner
  to Air;

state Randomizer "?"
 is Support;

state ConveyorLeft "<"
  to ConveyorRight when v Randomizer and guess;

state ConveyorRight ">"
  to ConveyorLeft when v Randomizer and guess;

state Torch "T".

/*** END ***/