Commits

Anonymous committed 3fae462

Tests for evolution of CA's, for more informative examples.

Comments (0)

Files changed (3)

doc/ALPACA.markdown

 However, to drive home that this is not necessarily the case, the
 verbiage "visual" and "appearance" has been avoided in this specification.
 
+#### Aside: Initial Configuration ####
+
+    -> Tests for functionality "Evolve ALPACA CA one generation"
+
+We describe the initial configuration now, as it will be useful for
+demonstrating the meanings of things in the core ALPACA description in
+the examples to follow.
+
+The list of definitions may end either with a period or the token
+`begin`.  If it is the token `begin`, the remainder of the file is
+assumed to contain an initial configuration for the cellular automton
+now defined.
+
+`begin` should be followed by a newline.  Each subsequent line of text
+contains characters which map to cells of the playfield in the initial
+configuration.
+
+Example:
+
+    | state Space " ";
+    | state Thing "*"
+    | begin
+    |  *
+    | ***
+    |  *
+    = -----
+    =  * 
+    = ***
+    =  * 
+    = -----
+
 #### Class Memberships ####
 
 Any number of classes may be named after the representation declarations,
 
 #### Transition Rules ####
 
+    -> Tests for functionality "Parse ALPACA Description"
+
 Each transition rule begins with `to`, gives a _state referent_ which
 specifes the state to which to transition, optionally followed by `when` and
 a _boolean expression_ describing the conditions under which the transition
     |   to Space when 3 in (^ v < >) Space.
     = ok
 
-### Initial Configuration ###
-
-The list of definitions may end either with a period or the token
-`begin`.  If it is the token `begin`, the remainder of the file is
-assumed to contain an initial configuration for the cellular automton
-now defined.
-
-`begin` should be followed by a newline.  Each subsequent line of text
-contains characters which map to cells of the playfield in the initial
-configuration.
+(TODO: the following example is out of place)
 
 Example: a glider, pointed northeast, in John Conway's Game of Life
 automaton:

src/alpaca/main.py

 """
-alpaca [-agpt] description.alp [form.ca]
+alpaca [-agIpt] description.alp [form.ca]
 
 Reference implementation of the ALPACA cellular automaton definition language,
 version 1.0-PRE.
                          dest="generations", default=None, type='int',
                          help="evolve CA for only the given number of "
                               "generations")
+    optparser.add_option("-I", "--hide-initial",
+                         action="store_false", dest="show_initial",
+                         default=True,
+                         help="don't show initial configuration")
     optparser.add_option("-p", "--parse-only",
                          action="store_true", dest="parse_only",
                          default=False,
         file.close()
 
     count = 0
-    print str(pf)
     print "-----"
+    if options.show_initial:
+        print str(pf),
+        print "-----"
     while True:
         new_pf = Playfield(default_state, repr_map)
         evolve_playfield(pf, new_pf, ast)
 cat >test_config <<EOF
     -> Functionality "Parse ALPACA Description" is implemented by shell command
     -> "./bin/alpaca -p %(test-file) && echo 'ok'"
+
+    -> Functionality "Evolve ALPACA CA one generation" is implemented by
+    -> shell command
+    -> "./bin/alpaca -I -g1 %(test-file)"
 EOF
 falderal test_config doc/ALPACA.markdown
 rm test_config