Courtesty of MIT student, used with permission.
For my final project, I made a system for defining context-free grammars (CFGs) and expanding a sequence of terminals into non-terminals using randomized productions. This contrasts with the more common activity of parsing a string of already-generated terminals into higher-level nonterminals,which is essentially the reverse process. A sequence of terminals can then be processed to produce some sort of output, such as a sound or a song. Using this system, complex definitions can be easily created as a series of productions, each of which maps a symbol to one or more probabilistically-weighted expansions, in order to create complex randomized, but structured, behavior.
Complete report (PDF)
Code files and sample audio outputs (ZIP) (This ZIP file contains 3 .py, 4 .yaml, and 2 .wav files). The audio files are a 1-second sound and a 4-second song.