Generative Poetry with L-Systems

by Adam Parrish

This program uses an L-System to re-order the words of a source text. The resulting text retains some of the semantics of the original text, but with a significantly modified structure whose rhythm is both similar and foreign to the ordinary rhythm of language.

Methodology

Graphical L-Systems commonly make use of a "turtle" metaphor, wherein each token in the expanded L-System string corresponds to a graphical operation (draw a line, move forward without drawing, rotate current heading, etc.). This program uses the same metaphor, except the "turtle" is limited to moving over a one-dimensional array of words. The only "draw" operations are printing the word at the current array index and advancing to the next line.

Recognized rule tokens:

Note: Decrementing/incrementing beyond the bounds of the array will cause the index to wrap, e.g., for a text with 100 words, an index of -6 is the same as 94, and an index of 109 is the same as 9.

Try It Out

Use the form below to try out the program yourself. Perl source code available here.

Axiom

This is the initial string to which the rules will be applied.
Rules

Format: X=Y, where X is the token to expand and Y is the tokens to replace X. Separate multiple rules with whitespace. See explanation above for valid tokens.
Depth

This variable controls how many times the rules will be recursively expanded.
Source text

Enter a series of white-space separated words here (cutting and pasting from a web page or text file should work fine). These words are the raw material for the poetry you're about to create.