git @ Cat's Eye Technologies REDGREEN / rel_1_1_2007_0722
Import of REDGREEN version 1.1 revision 2007.0722 sources. catseye 9 years ago
4 changed file(s) with 44 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
88 <h2>Cellular Automaton</h2>
99
1010 <p>REDGREEN is a successor to <a href="/projects/rube/">RUBE</a>.
11 REDGREEN is a true cellular automaton (CA) and written in a much clearer language
12 in which to express CA's, <a href="/projects/alpaca/">ALPACA</a>.
13 REDGREEN is an extremely complex automaton, making full use of
14 ALPACA's "class of states" feature.</p>
11 Unlike RUBE, REDGREEN is proper cellular automaton (CA): the next
12 state of each cell is determined only by its current state and
13 the states of its neighbours.</p>
1514
1615 <h2>Implementation</h2>
1716
18 <p>You can download the ALPACA v0.90
19 distribution from this web server.
20 It contains the ALPACA compiler, of which REDGREEN is one of the
21 example CA descriptions.</p>
17 <p>This implementation of REDGREEN is written in <a href="/projects/alpaca/">ALPACA</a>
18 and compiled to a Perl script using the reference ALPACA compiler.
19 As a language for expressing CA's, ALPACA is much, much clearer than
20 C (the language in which RUBE was implemented.) In fact, the need for
21 a clear description language for RUBE's successor was one of the driving
22 forces behind the development of ALPACA.
23 REDGREEN is an extremely complex automaton, making full use of
24 ALPACA's "class of states" feature.</p>
2225
2326 <h2>The REDGREEN Universe</h2>
2427
4043 Heavy things like pebbles fall through fire; water puts it out.
4144 Requires flammable fuel and air to keep burning, otherwise
4245 goes up in smoke. Spreads to adjacent flammables like twigs
43 and heats up adjacent inflammables like rock.
46 and heats up adjacent non-flammables like rock.
4447 </td></tr>
4548
4649 <tr><td>Earth</td><td> <b><tt>#</tt></b></td><td>
7982 </td></tr>
8083
8184 <tr><td>Spark</td><td> <b><tt>*</tt></b></td><td>
82 An electrical phenomenon living a <A HREF="/projects/alpaca/eg/wireworld/">WireWorld</a> existance.
85 An electrical phenomenon living a <A HREF="/projects/alpaca/eg/wireworld/">WireWorld</a> existence.
8386 </td></tr>
8487
8588 <tr><td>Tail</td><td> <b><tt>-</tt></b></td><td>
33 ====*-=====================*======
44 = =
55 ===-*======================*======
6 = llll
7 = === lllll
8 = = = llll
9 = = = <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
10 = = =
11 = =
12 =====
6 = llll
7 = === lllll
8 = = = llll
9 = = = <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
10 = = =
11 = = #
12 = =
13 = =
14 = =
15 = =
16 ==========
1317
00 #!/usr/bin/perl
1 # eg/redgreen/script/redgreen.pl - automatically generated from eg/redgreen/src/redgreen.alp by:
1 # - automatically generated from src/redgreen.alp by:
22 # alpaca.pl v0.93
33 # http://catseye.webhop.net/projects/alpaca/
44 ######################################################
108108 };
109109
110110 sub WireStateRules {
111 return 'Spark' if ((adjacent_state('Spark') >= 1) and (not (adjacent_state('Spark') >= 4)));
111 return 'Spark' if ((adjacent_state('Spark') >= 1) and (not (adjacent_state('Spark') >= 3)));
112112 return SupportClassRules() || 'Wire'
113113 };
114114
127127
128128 sub ZappyStateRules {
129129 return 'BigZappy' if (1);
130 return PassthruClassRules() || 'Zappy'
130 return PassthruClassRules() || BurnerClassRules() || 'Zappy'
131131 };
132132
133133 sub BigZappyStateRules {
134134 return 'Air' if (1);
135 return PassthruClassRules() || 'BigZappy'
135 return PassthruClassRules() || BurnerClassRules() || 'BigZappy'
136136 };
137137
138138 sub RandomizerStateRules {
157157 return $_[0] eq 'Fire' ||
158158 $_[0] eq 'Magma' ||
159159 $_[0] eq 'Spark' ||
160 $_[0] eq 'Zappy' ||
161 $_[0] eq 'BigZappy' ||
160162 0
161163 };
162164
00 /*
1 * REDGREEN.ALP - REDGREEN description in ALPACA
2 * v0.60 Jul 28 1998 Chris Pressey
3 * Added BSD License May 3 2007
1 * REDGREEN.ALP - REDGREEN description in ALPACA, v2007.0722
42 */
53
64 /*
3331 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
3432 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3533 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 /*
37 * History:
38 * Jul 28 1998: Original version (0.60)
39 * May 3 2007: Added BSD License
40 * Jul 22 2007: fixed behaviour of Wire, Zappy, and BigZappy, thanks to
41 * bug report by Stewart Gordon. Following the REDGREEN
42 * description in doc/redgreen.html, Wire now conforms to
43 * WireWorld rules, and Zappy and BigZappy are now Burner.
3644 */
3745
3846 /*** BEGIN ***/
127135
128136 state Wire "="
129137 is Support
130 to Spark when 1 Spark and not 4 Spark;
138 to Spark when 1 Spark and not 3 Spark;
131139
132140 state DuctTape "D"
133141 is Support
145153
146154 state Zappy "z"
147155 is Passthru
156 is Burner
148157 to BigZappy;
149158
150159 state BigZappy "Z"
151160 is Passthru
161 is Burner
152162 to Air;
153163
154164 state Randomizer "?"