git @ Cat's Eye Technologies ALPACA / acd2c0d
More tests for CA evolution... need to implement classes. catseye 12 years ago
1 changed file(s) with 62 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
227227 = -----
228228
229229 ##### Boolean Expressions #####
230
231 -> Tests for functionality "Parse ALPACA Description"
232230
233231 The boolean expression may be:
234232
254252 Example: a cellular automaton where `Thing`s become `Spaces` only
255253 if the cell to the east is a `Thing`:
256254
257 | state Space;
258 | state Thing
259 | to Space when > Thing.
260 = ok
255 | state Space " ";
256 | state Thing "*"
257 | to Space when > Thing
258 | begin
259 | *
260 | **
261 = -----
262 = *
263 = *
264 = -----
261265
262266 For more clarity, an equals sign may occur between the two state referents.
263267
264268 Example: a cellular automaton where `Thing`s become `Space`s only
265269 if the cell to the north and the cell to the south are the same state:
266270
267 | state Space;
268 | state Thing
269 | to Space when ^ = v.
270 = ok
271 | state Space " ";
272 | state Thing "*"
273 | to Space when ^ = v
274 | begin
275 | *
276 | **
277 = -----
278 = *
279 = *
280 = -----
271281
272282 A class-inclusion predicate is similar to a state predicate, but instead
273283 of a state referent, the second term is a class referent. An example will
287297 Example: a cellular automaton where `Thing`s become `Space`s only if they
288298 are not adjacent to three other `Thing`s.
289299
290 | state Space;
291 | state Thing
292 | to Space when not 3 Thing.
293 = ok
300 | state Space " ";
301 | state Thing "*"
302 | to Space when not 3 Thing
303 | begin
304 | *
305 | **
306 | *
307 = -----
308 = **
309 = -----
294310
295311 ### Classes ###
296312
303319 a state of the other type to the north, but they will both turn into
304320 `Space` when there is a `Space` to the east.
305321
306 | state Space;
322 | state Space " ";
307323 | class Animal
308324 | to Space when > Space;
309 | state Dog is Animal
325 | state Dog "d" is Animal
310326 | to Cat when ^ Cat;
311 | state Cat is Animal
312 | to Dog when ^ Dog.
313 = ok
327 | state Cat "c" is Animal
328 | to Dog when ^ Dog
329 | begin
330 | ccd
331 | dcc
332 = -----
333 = dc
334 = cc
335 = -----
314336
315337 Each state can belong to zero or more classes. When it belongs to more
316338 than one, class the transition rules for each class are applied in order
323345 In it, `One`s always remain `One`s, `Two`s always remain `Two`s, and `Three`s
324346 always remain `Three`s.
325347
348 | state Space " ";
326349 | class AlphaType
327350 | to One when true;
328351 | class BetaType
329352 | to Two when true;
330 | state One is AlphaType is BetaType;
331 | state Two is BetaType is AlphaType;
332 | state Three is BetaType is AlphaType
333 | to Three when true.
334 = ok
353 | state One "1" is AlphaType is BetaType;
354 | state Two "2" is BetaType is AlphaType;
355 | state Three "3" is BetaType is AlphaType
356 | to Three when true
357 | begin
358 | 123
359 = -----
360 = 123
361 = -----
335362
336363 In a transition rule, a class-inclusion predicate may be used by
337364 giving a state referent, the token `is`, and the name of a class.
342369 switch to the other when the cell to the north is not an `Animal` and turn
343370 to `Space` when the cell to the east is an `Animal`.
344371
345 | state Space;
372 | state Space " ";
346373 | class Animal
347374 | to Space when > is Animal;
348 | state Dog is Animal
375 | state Dog "d" is Animal
349376 | to Cat when not ^ is Animal;
350 | state Cat is Animal
351 | to Dog when not ^ is Animal.
352 = ok
377 | state Cat "c" is Animal
378 | to Dog when not ^ is Animal
379 | begin
380 | dcdc
381 = -----
382 = dcdc
383 = -----
353384
354385 ### Neighbourhoods ###
386
387 -> Tests for functionality "Parse ALPACA Description"
355388
356389 A neighbourhood is a set of positions relative to a cell. A neighbourhood
357390 is specified in ALPACA with a sequence of arrow chains inside parentheses.