A prototype to explore genetic programming of drawings.
We are going to use the following language to describe our drawings.
program = 'program(' sequence ');'
sequence = 'sequence()' | 'sequence(' action (',' action)* ')'
action = turn
| step
| sequence
turn = 'left()'
| 'right()'
step = 'forward()'
The following machine will execute our programs. It maintains a directions which can be one of north, east, south or west. The direction is initialized to be north.
The machine will perform the following actions:
left()
: change direction counter clockwise along the compass.right()
: change direction clockwise along the compass.forward()
: take a step in direction leaving a trail.- sequence: perform the actions in sequence.
The following programs are all valid.
program(sequence());
program(sequence(forward()));
program(sequence(forward(),left(),forward(),left(),forward(),left(),forward(),left()));
program(sequence(sequence(forward(),left(),forward()),sequence(forward(),right(),forward())));