Initial import of REDGREEN version 1.0 revision 2007.0503 sources.
catseye
12 years ago
0 | <html><head> | |
1 | <meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1"> | |
2 | <meta name="Description" content="Cat's Eye Technologies: The REDGREEN Cellular Automaton"> | |
3 | <title>Cat's Eye Technologies: The REDGREEN Cellular Automaton</title> | |
4 | </head> | |
5 | <body> | |
6 | <h1>REDGREEN</h1> | |
7 | ||
8 | <h2>Cellular Automaton</h2> | |
9 | ||
10 | <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> | |
15 | ||
16 | <h2>Implementation</h2> | |
17 | ||
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> | |
22 | ||
23 | <h2>The REDGREEN Universe</h2> | |
24 | ||
25 | <table> | |
26 | <tr><td>Air</td><td> </td><td> | |
27 | Heavy things like water and pebbles fall through air. | |
28 | Light things like smoke and steam rise in air. | |
29 | Air is required for a fire to keep burning. | |
30 | </td></tr> | |
31 | ||
32 | <tr><td>Water</td><td> <b><tt>~</tt></b></td><td> | |
33 | Heavy solid things like pebbles fall into water. | |
34 | Light things like steam or smoke make rising bubbles in water. | |
35 | Boils to steam when heated, but also puts out open fires. | |
36 | Fish can live a John Conway's Life in water. | |
37 | </td></tr> | |
38 | ||
39 | <tr><td>Fire</td><td> <b><tt>%</tt></b></td><td> | |
40 | Heavy things like pebbles fall through fire; water puts it out. | |
41 | Requires flammable fuel and air to keep burning, otherwise | |
42 | goes up in smoke. Spreads to adjacent flammables like twigs | |
43 | and heats up adjacent inflammables like rock. | |
44 | </td></tr> | |
45 | ||
46 | <tr><td>Earth</td><td> <b><tt>#</tt></b></td><td> | |
47 | Stops things which would otherwise fall from falling. Can be | |
48 | heated up to magma by adjacent fire. | |
49 | </td></tr> | |
50 | ||
51 | ||
52 | <tr><td>Magma</td><td> <b><tt>&</tt></b></td><td> | |
53 | Heated-up earth, will cool down to earth if no adjacent fire or | |
54 | magma is present. Can boil water. | |
55 | </td></tr> | |
56 | ||
57 | <tr><td>Steam</td><td> <b><tt>s</tt></b></td><td> | |
58 | From boiling water, rises in air. | |
59 | </td></tr> | |
60 | ||
61 | <tr><td>Smoke</td><td> <b><tt>@</tt></b></td><td> | |
62 | From fire, rises in air. | |
63 | </td></tr> | |
64 | ||
65 | <tr><td>Bubble</td><td> <b><tt>o</tt></b></td><td> | |
66 | From air or steam or smoke, rises in water. | |
67 | </td></tr> | |
68 | ||
69 | <tr><td>Fish</td><td> <b><tt>f</tt></b></td><td> | |
70 | Lives a <A HREF="/projects/alpaca/eg/life/">John Conway's Life</a> in water. | |
71 | </td></tr> | |
72 | ||
73 | <tr><td>Pebble</td><td> <b><tt>.</tt></b></td><td> | |
74 | Falls through air. | |
75 | </td></tr> | |
76 | ||
77 | <tr><td>Two Pebbles</td><td> <b><tt>:</tt></b></td><td> | |
78 | Two pebbles stacked together, also falls through air. | |
79 | </td></tr> | |
80 | ||
81 | <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. | |
83 | </td></tr> | |
84 | ||
85 | <tr><td>Tail</td><td> <b><tt>-</tt></b></td><td> | |
86 | The trail of a spark. | |
87 | </td></tr> | |
88 | ||
89 | <tr><td>Wire</td><td> <b><tt>=</tt></b></td><td> | |
90 | Conducts electricity (sparks). | |
91 | </td></tr> | |
92 | ||
93 | <tr><td>Zappy</td><td> <b><tt>z</tt></b></td><td> | |
94 | Shot off by sparks. Can set flammables on fire. | |
95 | </td></tr> | |
96 | ||
97 | <tr><td>Big Zappy</td><td> <b><tt>Z</tt></b></td><td> | |
98 | Also shot off by sparks. Can also set flammables on fire. | |
99 | </td></tr> | |
100 | ||
101 | <tr><td>Duct Tape</td><td> <b><tt>D</tt></b></td><td> | |
102 | Flammable. Things can stick to it. It can unravel. | |
103 | </td></tr> | |
104 | ||
105 | <tr><td>"Oh No" Tape</td><td> <b><tt>O</tt></b></td><td> | |
106 | Flammable. Duct tape that's unravelling. | |
107 | </td></tr> | |
108 | ||
109 | <tr><td>Twig</td><td> <b><tt>l</tt></b></td><td> | |
110 | Flammable. | |
111 | </td></tr> | |
112 | ||
113 | <tr><td>Conveyor Left</td><td> <b><tt><</tt></b></td><td> | |
114 | Moves twigs, pebbles etc. on top of it to the left. | |
115 | </td></tr> | |
116 | ||
117 | <tr><td>Conveyor Right</td><td> <b><tt>></tt></b></td><td> | |
118 | Moves twigs, pebbles etc. on top of it to the right. | |
119 | </td></tr> | |
120 | ||
121 | <tr><td>Randomizer</td><td> <b><tt>?</tt></b></td><td> | |
122 | Randomly flips the direction of the Conveyor adjacent | |
123 | above it. | |
124 | </td></tr> | |
125 | ||
126 | <tr><td>Torch</td><td> <b><tt>T</tt></b></td><td> | |
127 | Provides endless fuel for a fire. | |
128 | </td></tr> | |
129 | ||
130 | </table> | |
131 | ||
132 | </body></html> |
0 | ||
1 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
2 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
3 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
4 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
5 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~f~~~~~~~~~~~~# | |
6 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~f~~~~~~~~~~~~~# | |
7 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~f~~~f~~~~~~~~~# | |
8 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ffff~~~~~~~~~~# | |
9 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
10 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
11 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
12 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
13 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
14 | #~~~ff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
15 | #~~f~f~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
16 | #~~~~f~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
17 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# | |
18 | #################################################### | |
19 |
0 | . | |
1 | ||
2 | ||
3 | ||
4 | > | |
5 | ? | |
6 | ||
7 | > > | |
8 | ? ? | |
9 | ||
10 | > > > | |
11 | ? ? ? | |
12 | ||
13 | > > > > | |
14 | ? ? ? ? | |
15 | ||
16 | > > > > > | |
17 | ? ? ? ? ? | |
18 | ||
19 | # # # # # # # | |
20 | ############# |
0 | ||
1 | # # | |
2 | ...... # # | |
3 | # ~ # | |
4 | ####################### # | |
5 | %# # | |
6 | . . . T ##### # | |
7 | ### # : # | |
8 | # # | |
9 | # . # | |
10 | # # | |
11 | # # | |
12 | # . # | |
13 | # # | |
14 | # # | |
15 | >>>>>>>>>>>>>>>##<<<<<<<<<<<<<<<<<############################ | |
16 | % | |
17 | T |
0 | ||
1 | ||
2 | ||
3 | ====*-=====================*====== | |
4 | = = | |
5 | ===-*======================*====== | |
6 | = llll | |
7 | = === lllll | |
8 | = = = llll | |
9 | = = = <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
10 | = = = | |
11 | = = | |
12 | ===== | |
13 |
0 | #!/usr/bin/perl | |
1 | # eg/redgreen/script/redgreen.pl - automatically generated from eg/redgreen/src/redgreen.alp by: | |
2 | # alpaca.pl v0.93 | |
3 | # http://catseye.webhop.net/projects/alpaca/ | |
4 | ###################################################### | |
5 | ||
6 | use Alpaca qw(true false guess | |
7 | adjacent_state adjacent_class | |
8 | load_playfield display_playfield process_playfield); | |
9 | ||
10 | sub FallableClassRules { | |
11 | return 'Air' if ((not SupportClassMember($Playfield->[$x][$y+1])) and (adjacent_state('Air') >= 2) and (not (adjacent_state('DuctTape') >= 1))); | |
12 | return 'Water' if ((not SupportClassMember($Playfield->[$x][$y+1])) and (adjacent_state('Water') >= 4) and (not (adjacent_state('DuctTape') >= 1))); | |
13 | return $Playfield->[$x][$y] if (($Playfield->[$x][$y+1] eq 'ConveyorLeft' and (not PassthruClassMember($Playfield->[$x-1][$y]))) or ($Playfield->[$x][$y+1] eq 'ConveyorRight' and (not PassthruClassMember($Playfield->[$x+1][$y])))); | |
14 | return 0 | |
15 | }; | |
16 | ||
17 | sub PassthruClassRules { | |
18 | return $Playfield->[$x][$y-1] if (FallableClassMember($Playfield->[$x][$y-1])); | |
19 | return $Playfield->[$x+1][$y] if (FallableClassMember($Playfield->[$x+1][$y]) and $Playfield->[$x+1][$y+1] eq 'ConveyorLeft'); | |
20 | return $Playfield->[$x-1][$y] if (FallableClassMember($Playfield->[$x-1][$y]) and $Playfield->[$x-1][$y+1] eq 'ConveyorRight'); | |
21 | return 0 | |
22 | }; | |
23 | ||
24 | sub FlammableClassRules { | |
25 | return 'Fire' if ((adjacent_class(\&BurnerClassMember) >= 1)); | |
26 | return 0 | |
27 | }; | |
28 | ||
29 | sub SteamyClassRules { | |
30 | return 'Water' if ($Playfield->[$x-1][$y] eq 'Water' or $Playfield->[$x+1][$y] eq 'Water' or $Playfield->[$x-1][$y-1] eq 'Water' or $Playfield->[$x+1][$y-1] eq 'Water' or $Playfield->[$x][$y-1] eq 'Water'); | |
31 | return 'Air' if (1); | |
32 | return 0 | |
33 | }; | |
34 | ||
35 | sub BurnerClassRules { | |
36 | return 0 | |
37 | }; | |
38 | ||
39 | sub SupportClassRules { | |
40 | return 0 | |
41 | }; | |
42 | ||
43 | sub AirStateRules { | |
44 | return 'Water' if ($Playfield->[$x][$y-1] eq 'Water' or $Playfield->[$x-1][$y-1] eq 'Water' or $Playfield->[$x+1][$y-1] eq 'Water' or ($Playfield->[$x-1][$y] eq 'Water' and SupportClassMember($Playfield->[$x-1][$y+1])) or ($Playfield->[$x-1][$y] eq 'Water' and $Playfield->[$x-1][$y+1] eq 'Water' and $Playfield->[$x][$y+1] eq 'Water') or ($Playfield->[$x+1][$y] eq 'Water' and SupportClassMember($Playfield->[$x+1][$y+1])) or ($Playfield->[$x+1][$y] eq 'Water' and $Playfield->[$x+1][$y+1] eq 'Water' and $Playfield->[$x][$y+1] eq 'Water')); | |
45 | return 'Steam' if ($Playfield->[$x][$y+1] eq 'Steam' or $Playfield->[$x-1][$y+1] eq 'Steam' or $Playfield->[$x+1][$y+1] eq 'Steam'); | |
46 | return 'Smoke' if ($Playfield->[$x][$y+1] eq 'Smoke' or $Playfield->[$x-1][$y+1] eq 'Smoke' or $Playfield->[$x+1][$y+1] eq 'Smoke'); | |
47 | return 'Zappy' if ((adjacent_state('Spark') >= 1)); | |
48 | return PassthruClassRules() || 'Air' | |
49 | }; | |
50 | ||
51 | sub WaterStateRules { | |
52 | return 'Steam' if ((adjacent_state('Fire') >= 1) or (adjacent_state('Magma') >= 1)); | |
53 | return 'Bubble' if ($Playfield->[$x][$y+1] eq 'Bubble' or $Playfield->[$x][$y+1] eq 'Smoke' or $Playfield->[$x][$y+1] eq 'Steam'); | |
54 | return 'Fish' if ((adjacent_state('Fish') >= 3) and (adjacent_state('Water') >= 5)); | |
55 | return PassthruClassRules() || 'Water' | |
56 | }; | |
57 | ||
58 | sub FireStateRules { | |
59 | return 'Smoke' if ((adjacent_state('Water') >= 1) or (not (adjacent_state('Air') >= 1)) or ((not (adjacent_state('Torch') >= 1)) and (not (adjacent_state('DuctTape') >= 1)) and (not (adjacent_state('Twig') >= 1)))); | |
60 | return PassthruClassRules() || BurnerClassRules() || 'Fire' | |
61 | }; | |
62 | ||
63 | sub EarthStateRules { | |
64 | return 'Magma' if ((adjacent_state('Fire') >= 1)); | |
65 | return SupportClassRules() || 'Earth' | |
66 | }; | |
67 | ||
68 | sub MagmaStateRules { | |
69 | return 'Earth' if ((not (adjacent_state('Fire') >= 1)) and (not (adjacent_state('Magma') >= 2))); | |
70 | return SupportClassRules() || BurnerClassRules() || 'Magma' | |
71 | }; | |
72 | ||
73 | sub SteamStateRules { | |
74 | return PassthruClassRules() || SteamyClassRules() || 'Steam' | |
75 | }; | |
76 | ||
77 | sub SmokeStateRules { | |
78 | return PassthruClassRules() || SteamyClassRules() || 'Smoke' | |
79 | }; | |
80 | ||
81 | sub BubbleStateRules { | |
82 | return PassthruClassRules() || SteamyClassRules() || 'Bubble' | |
83 | }; | |
84 | ||
85 | sub FishStateRules { | |
86 | return 'Air' if ((not (adjacent_state('Water') >= 1))); | |
87 | return 'Water' if ((adjacent_state('Fish') >= 4) or (adjacent_state('Water') >= 7)); | |
88 | return 'Fish' | |
89 | }; | |
90 | ||
91 | sub OnePebbleStateRules { | |
92 | return 'TwoPebble' if ($Playfield->[$x][$y-1] eq 'OnePebble' and (SupportClassMember($Playfield->[$x][$y+1]))); | |
93 | return FallableClassRules() || 'OnePebble' | |
94 | }; | |
95 | ||
96 | sub TwoPebbleStateRules { | |
97 | return FallableClassRules() || SupportClassRules() || 'TwoPebble' | |
98 | }; | |
99 | ||
100 | sub SparkStateRules { | |
101 | return 'Tail' if (1); | |
102 | return SupportClassRules() || BurnerClassRules() || 'Spark' | |
103 | }; | |
104 | ||
105 | sub TailStateRules { | |
106 | return 'Wire' if (1); | |
107 | return SupportClassRules() || 'Tail' | |
108 | }; | |
109 | ||
110 | sub WireStateRules { | |
111 | return 'Spark' if ((adjacent_state('Spark') >= 1) and (not (adjacent_state('Spark') >= 4))); | |
112 | return SupportClassRules() || 'Wire' | |
113 | }; | |
114 | ||
115 | sub DuctTapeStateRules { | |
116 | return 'UnravelTape' if (((not (adjacent_state('DuctTape') >= 2))) or ((not ((adjacent_state('DuctTape') >= 1) and (adjacent_class(\&SupportClassMember) >= 1))))); | |
117 | return SupportClassRules() || FlammableClassRules() || 'DuctTape' | |
118 | }; | |
119 | ||
120 | sub UnravelTapeStateRules { | |
121 | return FallableClassRules() || FlammableClassRules() || 'UnravelTape' | |
122 | }; | |
123 | ||
124 | sub TwigStateRules { | |
125 | return FallableClassRules() || SupportClassRules() || FlammableClassRules() || 'Twig' | |
126 | }; | |
127 | ||
128 | sub ZappyStateRules { | |
129 | return 'BigZappy' if (1); | |
130 | return PassthruClassRules() || 'Zappy' | |
131 | }; | |
132 | ||
133 | sub BigZappyStateRules { | |
134 | return 'Air' if (1); | |
135 | return PassthruClassRules() || 'BigZappy' | |
136 | }; | |
137 | ||
138 | sub RandomizerStateRules { | |
139 | return SupportClassRules() || 'Randomizer' | |
140 | }; | |
141 | ||
142 | sub ConveyorLeftStateRules { | |
143 | return 'ConveyorRight' if ($Playfield->[$x][$y+1] eq 'Randomizer' and guess()); | |
144 | return 'ConveyorLeft' | |
145 | }; | |
146 | ||
147 | sub ConveyorRightStateRules { | |
148 | return 'ConveyorLeft' if ($Playfield->[$x][$y+1] eq 'Randomizer' and guess()); | |
149 | return 'ConveyorRight' | |
150 | }; | |
151 | ||
152 | sub TorchStateRules { | |
153 | return 'Torch' | |
154 | }; | |
155 | ||
156 | sub BurnerClassMember { | |
157 | return $_[0] eq 'Fire' || | |
158 | $_[0] eq 'Magma' || | |
159 | $_[0] eq 'Spark' || | |
160 | 0 | |
161 | }; | |
162 | ||
163 | sub FallableClassMember { | |
164 | return $_[0] eq 'OnePebble' || | |
165 | $_[0] eq 'TwoPebble' || | |
166 | $_[0] eq 'UnravelTape' || | |
167 | $_[0] eq 'Twig' || | |
168 | 0 | |
169 | }; | |
170 | ||
171 | sub FlammableClassMember { | |
172 | return $_[0] eq 'DuctTape' || | |
173 | $_[0] eq 'UnravelTape' || | |
174 | $_[0] eq 'Twig' || | |
175 | 0 | |
176 | }; | |
177 | ||
178 | sub PassthruClassMember { | |
179 | return $_[0] eq 'Air' || | |
180 | $_[0] eq 'Water' || | |
181 | $_[0] eq 'Fire' || | |
182 | $_[0] eq 'Steam' || | |
183 | $_[0] eq 'Smoke' || | |
184 | $_[0] eq 'Bubble' || | |
185 | $_[0] eq 'Zappy' || | |
186 | $_[0] eq 'BigZappy' || | |
187 | 0 | |
188 | }; | |
189 | ||
190 | sub SteamyClassMember { | |
191 | return $_[0] eq 'Steam' || | |
192 | $_[0] eq 'Smoke' || | |
193 | $_[0] eq 'Bubble' || | |
194 | 0 | |
195 | }; | |
196 | ||
197 | sub SupportClassMember { | |
198 | return $_[0] eq 'Earth' || | |
199 | $_[0] eq 'Magma' || | |
200 | $_[0] eq 'TwoPebble' || | |
201 | $_[0] eq 'Spark' || | |
202 | $_[0] eq 'Tail' || | |
203 | $_[0] eq 'Wire' || | |
204 | $_[0] eq 'DuctTape' || | |
205 | $_[0] eq 'Twig' || | |
206 | $_[0] eq 'Randomizer' || | |
207 | 0 | |
208 | }; | |
209 | ||
210 | $Appearance = { | |
211 | 'Air' => ' ', | |
212 | 'BigZappy' => 'Z', | |
213 | 'Bubble' => 'o', | |
214 | 'ConveyorLeft' => '<', | |
215 | 'ConveyorRight' => '>', | |
216 | 'DuctTape' => 'D', | |
217 | 'Earth' => '#', | |
218 | 'Fire' => '%', | |
219 | 'Fish' => 'f', | |
220 | 'Magma' => '&', | |
221 | 'OnePebble' => '.', | |
222 | 'Randomizer' => '?', | |
223 | 'Smoke' => '@', | |
224 | 'Spark' => '*', | |
225 | 'Steam' => 's', | |
226 | 'Tail' => '-', | |
227 | 'Torch' => 'T', | |
228 | 'Twig' => 'l', | |
229 | 'TwoPebble' => ':', | |
230 | 'UnravelTape' => 'O', | |
231 | 'Water' => '~', | |
232 | 'Wire' => '=', | |
233 | 'Zappy' => 'z', | |
234 | ||
235 | }; | |
236 | ||
237 | $InputCodec = { | |
238 | ' ' => 'Air', | |
239 | 'Z' => 'BigZappy', | |
240 | 'o' => 'Bubble', | |
241 | '<' => 'ConveyorLeft', | |
242 | '>' => 'ConveyorRight', | |
243 | 'D' => 'DuctTape', | |
244 | '#' => 'Earth', | |
245 | '%' => 'Fire', | |
246 | 'f' => 'Fish', | |
247 | '&' => 'Magma', | |
248 | '.' => 'OnePebble', | |
249 | '?' => 'Randomizer', | |
250 | '@' => 'Smoke', | |
251 | '*' => 'Spark', | |
252 | 's' => 'Steam', | |
253 | '-' => 'Tail', | |
254 | 'T' => 'Torch', | |
255 | 'l' => 'Twig', | |
256 | ':' => 'TwoPebble', | |
257 | 'O' => 'UnravelTape', | |
258 | '~' => 'Water', | |
259 | '=' => 'Wire', | |
260 | 'z' => 'Zappy', | |
261 | ||
262 | }; | |
263 | ||
264 | $StateRule = { | |
265 | 'Air' => \&main::AirStateRules, | |
266 | 'BigZappy' => \&main::BigZappyStateRules, | |
267 | 'Bubble' => \&main::BubbleStateRules, | |
268 | 'ConveyorLeft' => \&main::ConveyorLeftStateRules, | |
269 | 'ConveyorRight' => \&main::ConveyorRightStateRules, | |
270 | 'DuctTape' => \&main::DuctTapeStateRules, | |
271 | 'Earth' => \&main::EarthStateRules, | |
272 | 'Fire' => \&main::FireStateRules, | |
273 | 'Fish' => \&main::FishStateRules, | |
274 | 'Magma' => \&main::MagmaStateRules, | |
275 | 'OnePebble' => \&main::OnePebbleStateRules, | |
276 | 'Randomizer' => \&main::RandomizerStateRules, | |
277 | 'Smoke' => \&main::SmokeStateRules, | |
278 | 'Spark' => \&main::SparkStateRules, | |
279 | 'Steam' => \&main::SteamStateRules, | |
280 | 'Tail' => \&main::TailStateRules, | |
281 | 'Torch' => \&main::TorchStateRules, | |
282 | 'Twig' => \&main::TwigStateRules, | |
283 | 'TwoPebble' => \&main::TwoPebbleStateRules, | |
284 | 'UnravelTape' => \&main::UnravelTapeStateRules, | |
285 | 'Water' => \&main::WaterStateRules, | |
286 | 'Wire' => \&main::WireStateRules, | |
287 | 'Zappy' => \&main::ZappyStateRules, | |
288 | ||
289 | }; | |
290 | ||
291 | load_playfield($ARGV[0]); | |
292 | ||
293 | display_playfield(); | |
294 | ||
295 | while (!$done) | |
296 | { | |
297 | process_playfield(); | |
298 | display_playfield(); | |
299 | } | |
300 | ||
301 | exit(0); | |
302 | ||
303 | ### END ### |
0 | /* | |
1 | * REDGREEN.ALP - REDGREEN description in ALPACA | |
2 | * v0.60 Jul 28 1998 Chris Pressey | |
3 | * Added BSD License May 3 2007 | |
4 | */ | |
5 | ||
6 | /* | |
7 | * Copyright (c)2007 Chris Pressey, Cat's Eye Technologies. | |
8 | * All rights reserved. | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | |
13 | * | |
14 | * 1. Redistributions of source code must retain the above copyright | |
15 | * notices, this list of conditions and the following disclaimer. | |
16 | * 2. Redistributions in binary form must reproduce the above copyright | |
17 | * notices, this list of conditions, and the following disclaimer in | |
18 | * the documentation and/or other materials provided with the | |
19 | * distribution. | |
20 | * 3. Neither the names of the copyright holders nor the names of their | |
21 | * contributors may be used to endorse or promote products derived | |
22 | * from this software without specific prior written permission. | |
23 | * | |
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
25 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT | |
26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
28 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
34 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | |
37 | ||
38 | /*** BEGIN ***/ | |
39 | ||
40 | /*** CLASSES ***/ | |
41 | ||
42 | class Fallable | |
43 | to Air when not v is Support and 2 Air and not 1 DuctTape, | |
44 | to Water when not v is Support and 4 Water and not 1 DuctTape, | |
45 | to me when (v ConveyorLeft and not < is Passthru) or (v ConveyorRight and not > is Passthru); | |
46 | ||
47 | class Passthru | |
48 | to ^ when ^ is Fallable, | |
49 | to > when > is Fallable and v> ConveyorLeft, | |
50 | to < when < is Fallable and v< ConveyorRight; | |
51 | ||
52 | class Flammable | |
53 | to Fire when 1 is Burner; | |
54 | ||
55 | class Steamy | |
56 | to Water when < Water or > Water or ^< Water or ^> Water or ^ Water, | |
57 | to Air; | |
58 | ||
59 | class Burner; | |
60 | class Support; | |
61 | ||
62 | /*** STATES ***/ | |
63 | ||
64 | state Air " " | |
65 | is Passthru | |
66 | to Water when ^ Water or ^< Water or ^> Water | |
67 | or (< Water and v< is Support) | |
68 | or (< Water and v< Water and v Water) | |
69 | or (> Water and v> is Support) | |
70 | or (> Water and v> Water and v Water), | |
71 | to Steam when v Steam or v< Steam or v> Steam, | |
72 | to Smoke when v Smoke or v< Smoke or v> Smoke, | |
73 | to Zappy when 1 Spark; | |
74 | ||
75 | state Water "~" | |
76 | is Passthru | |
77 | to Steam when 1 Fire or 1 Magma, | |
78 | to Bubble when v Bubble or v Smoke or v Steam, | |
79 | to Fish when 3 Fish and 5 Water; | |
80 | ||
81 | state Fire "%" | |
82 | is Passthru | |
83 | is Burner | |
84 | to Smoke when 1 Water or not 1 Air or (not 1 Torch and not 1 DuctTape and not 1 Twig); | |
85 | ||
86 | state Earth "#" | |
87 | is Support | |
88 | to Magma when 1 Fire; | |
89 | ||
90 | state Magma "&" | |
91 | is Support | |
92 | is Burner | |
93 | to Earth when not 1 Fire and not 2 Magma; | |
94 | ||
95 | state Steam "s" | |
96 | is Passthru | |
97 | is Steamy; | |
98 | ||
99 | state Smoke "@" | |
100 | is Passthru | |
101 | is Steamy; | |
102 | ||
103 | state Bubble "o" | |
104 | is Passthru | |
105 | is Steamy; | |
106 | ||
107 | state Fish "f" | |
108 | to Air when not 1 Water, | |
109 | to Water when 4 Fish or 7 Water; | |
110 | ||
111 | state OnePebble "." | |
112 | is Fallable | |
113 | to TwoPebble when ^ OnePebble and (v is Support); | |
114 | ||
115 | state TwoPebble ":" | |
116 | is Fallable | |
117 | is Support; | |
118 | ||
119 | state Spark "*" | |
120 | is Support | |
121 | is Burner | |
122 | to Tail; | |
123 | ||
124 | state Tail "-" | |
125 | is Support | |
126 | to Wire; | |
127 | ||
128 | state Wire "=" | |
129 | is Support | |
130 | to Spark when 1 Spark and not 4 Spark; | |
131 | ||
132 | state DuctTape "D" | |
133 | is Support | |
134 | is Flammable | |
135 | to UnravelTape when (not 2 DuctTape) or (not (1 DuctTape and 1 is Support)); | |
136 | ||
137 | state UnravelTape "O" | |
138 | is Fallable | |
139 | is Flammable; | |
140 | ||
141 | state Twig "l" | |
142 | is Fallable | |
143 | is Support | |
144 | is Flammable; | |
145 | ||
146 | state Zappy "z" | |
147 | is Passthru | |
148 | to BigZappy; | |
149 | ||
150 | state BigZappy "Z" | |
151 | is Passthru | |
152 | to Air; | |
153 | ||
154 | state Randomizer "?" | |
155 | is Support; | |
156 | ||
157 | state ConveyorLeft "<" | |
158 | to ConveyorRight when v Randomizer and guess; | |
159 | ||
160 | state ConveyorRight ">" | |
161 | to ConveyorLeft when v Randomizer and guess; | |
162 | ||
163 | state Torch "T". | |
164 | ||
165 | /*** END ***/ |