Tree @master (Download .tar.gz)
Compiling ALPACA to Javascript.md @master — view markup · raw · history · blame
Compiling ALPACA to Javascript
This document describes a functionality of which the ALPACA reference implementation is capable, but is not a part of the ALPACA specification.
The reference implementation is able to compile an ALPACA description to a set of Javascript functions which, when called, will evolve a form for that cellular automaton.
These functions assume each generation is stored in a data structure called a playfield, which has two methods:
get(x, y)
: retrieve the name of the state at (x, y)map(new_pf, fun, min_x, min_y, max_x, max_y)
: applyfun
to every cell of the playfield to obtain a new playfield
In addition, if the ALPACA description supplies an initial playfield,
the Javascript compiler will generate two var
variables:
defaultCell
, which is a string that contains the name of the state that cells that have never been modified assume by defaultinitialPlayfield
, which is an array of triples (3-element arrays); each triple consists of x co-ordinate, y co-ordinate, and state name.
This interface can be used by additional Javascript code to evolve the automaton that the ALPACA description describes.