Source

REDGREEN / src / redgreen.alp

Full commit
/*
 * REDGREEN.ALP - REDGREEN description in ALPACA, v2007.0722
 */

/*
 * Copyright (c)2007 Chris Pressey, Cat's Eye Technologies.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notices, this list of conditions and the following disclaimer.
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notices, this list of conditions, and the following disclaimer in
 *      the documentation and/or other materials provided with the
 *      distribution.
 *   3. Neither the names of the copyright holders nor the names of their
 *      contributors may be used to endorse or promote products derived
 *      from this software without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * 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.
 */

/*** 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 ***/