Key case matters.
SPACE
... unpause program execution (programs are loaded paused)x
... reload current program (e.g. when terminal size changed or when in undesired state)B/M/T
... when paused simulate a single long/medium/instant step manually (rule application)
- load a program config
- choose a trigger key based either on time lapse (B/M/T) or user pressed keys
- for the given trigger key find all applicable rules in the current state (based on non-terminals and their context)
- choose randomly one of the rules (sample according to rule weights if unequal)
- apply the chosen rule to change state and optionally alter score and/or play sound
- repeat from 2. if the chosen rule is not a special rule:
- quit rule (exit to shell)
- program switching rule (load a given program and repeat from 2.)
Lines starting with
#
... comments or preliminary setup^
... initial symbol and its position=
... rule or special rule header- otherwise the line forms a part of body belonging to the preceding rule headers
Rules consist of one or more headers, and a rule body.
For the rule to be applicable to a char on screen these conditions must be met:
- trigger char matches
- non-terminal char matches with the char on screen at the given position
- surrounding context matches
=<s-char><nonterminal-char><trigger-char><fore-color-char><bg-color-char><extra-context-char><extra-replacement-char><z-order-char> <rule-score-num> <rule-weight-num>
i.e. these chars and tokens left to right =S12345678 <score> <weight>
S.
=
for silence or a sound char previously defined using dictionary comments, i.e.#=S<relative/path/to/file.wav>
1.
LHS non-terminal character (obligatory)2.
trigger char (a rule is invoked by pressing corresponding key or by B/M/T time steps) (obligatory)3.
RHS non-terminal replacement character (first @ in the rule body to be replaced by this char) (obligatory)4.
foreground char (0
black,1
red,2
green,3
yellow,4
blue,5
magenta,6
cyan,7
white) (default7
) or a dictionary entry value if not a digit5.
background char (same as foreground plus8
for transparent) (default8
)6.
extra required context char (special values:?
for any,*
for LHS char,$
for char saved in memory,#
for out-of-screen,~
empty space) at each char&
in the rule body7.
extra required context replacement (char to replace&
in the rule body, special values:~
space)8.
z-order layer char (greater values in front) (defaulta
)<score>
integer (default0
)<weight>
positive integer (default1
)
Specifying multiple headers for a single body is a shortcut equivalent to creating multiple single-header rules with the same body.
Contains three @
symbols at its core.
- First
@
... defines the relative LHS position of the non-terminal symbol - Second
@
... marks the boundary between the LHS (required context) and RHS (replacement) - Third
@
... defines the relative position of the RHS non-terminal replacement
Minimal example:
# on an instant time step silently replace A with B
==ATB
@@@
Example:
# when user presses key `e` rewrite A with B (if surrounded by x's)
# and surrounding x's by o's (play sound C) and color the foreground
# in red and background in yellow
=CAeB13
x o
x@x@o@o
x o
# when user presses key `e` rewrite B with A (if surrounded by o's)
# and surrounding o's by x's (silently) and color the foreground
# in yellow and background in blue
==BeA34
o x
o@o@x@x
o x
Complex example (shortcut combining both the above rules):
=CAeB13xo
==BeA34ox
& &
&@&@&@&
& &
One or more lines beginning with ^
required.
^<inital-symbol-char><vertical-placement-char><horizontal-placement-char>
The chars can be one of the following. There are uppercase variants to force column indices divisible by 2 to allow defining full-block (double the character width) grammars, for the more or less square look of the 'pixels'.
- vertical
u
upper rowl
lower rowL
lower row but index divisible by 2c
approximate middle rowC
approximate middle row with index divisible by 2X
random row but index divisible by 2<other>
random row
- horizontal
l
left edge of the screenr
right edge of the screenR
right edge of the screen but divisible by 2c
approximate center columnC
approximate center column divisible by twoX
random column but divisible with 2<other>
random column
#!<Program description>
... defines a help string shown on top when program execution is paused (e.g. on load) (has to be the first line of a program file)#=<single-char-key><value-string>
... defines a dictionary entry saved under a single char key, used to:- define sounds (by a relative path to a wav file)
- define colors (to allow changing colors for multiple rules at once)
#=T <B-step-ms> <M-step-ms> <T-step-ms>
... define timing steps (long/medium/instant) in milliseconds; if not given defaults to 500/50/0
Quit rule
The <replacement-char>
is irrelevant; trigger, non-terminal and its potential context in the rule body must be met for the rule to work.
=<s-char><nonterminal-char><trigger-char><replacement-char> quit
<left-context>@<right-context>@@
Program switching rule
Switches to a different program in runtime.
=<s-char><nonterminal-char><trigger-char><replacement-char> <relative/program/path/and/filename.cfg>`
<left-context>@<right-context>@@
The <s-char>
can be on of the following
>
keeps the previous screen content, switches to a given program running it immediately]
keeps the previous screen content, switches to a given program paused)
clears the screen, switches to a given program running it immediately|
clears the screen, switches to a given program paused
Not yet covered by this introduction:
- special chars
!
and%
in rule bodies. - local memory (used e.g. in
flowers.cfg
) #
char as an implicit (outer) screen boundary