In computing, procedural generation is a method of creating data algorithmically as opposed to manually, typically through a combination of human-generated assets and algorithms coupled with computer-generated randomness and processing power.
A Process for Creation of Content
- Uses curated rules or building blocks
- Plus usually a Sprinkle of Randomization
- An an Engine to make sense of it all.
.. it's usually code that uses small bits of content legos, put together in random ways to create dynamic content that can cover a wide range of possibilities in place of static content.
Thing | Details |
---|---|
Dwarf Fortress | The deepest, most intricate simulation of a world that's ever been created. |
Art Toy | A beautiful animated flower generator, that relies on an array of ints as 'genes'. |
Cave of Qud | Is a science fantasy RPG & roguelike epic. It's set in a far future that's deeply simulated, richly cultured, and rife with sentient plants. |
Spore | Spore is a 2008 life simulation real-time strategy God game developed by Maxis, published by Electronic Arts and designed by Will Wright. |
Nested | A universe simulator. |
If you can define it. You can generate it.
- Procedurally Generated Beethoven
- SkyKnit - Procedurally Generated Knitting
- Procedural Generated Terrain
.... the problem is in the defining.
SCOPE - The Problem
You've decided to SIMULATE THE WORLD!
Everything's so big!
And all the details so intricate.
And there's SO many edge cases!
I could be defining things FOREVER
SCOPE - The Solution
START SMALL!
Small parts.
Small pieces.
Small timeline!
OATMEAL - The Problem
You've got everything down to the smallest oat able to be generated in infinite detail!
There's lots of detail!
And SO much variation!
... but very little observable difference.
... and thus ultimately little impact.
OATMEAL - The Solution
FAIL FAST!
Try it.
Tweak it.
Expand it!
... basically this should sound a lot like writing most software. Find your MVP and iterate iterate iterate!
One of my Favorite Proc Gen Tools;
An author-focused, curated, simple text generation tool by Kate Compton
- Originally Written in Javascript (but 'ported to many others!)
- Requires a JSON structured Grammar
- Expands rules to generate text...
- ... but remember, html is ultimately just a special text!
We consider the potential authors for such a generative tool to be creative persons who are interested in the expressivity of language and the aesthetics of prose. They may not self-identify as ‘programmers’ or want to write code, but they want to create generative text that is algorithmically combinatorial and surprising, while still seeing their authorial ‘voice’ in the finished text.
Tracery's backbone is built on the concept of grammars; written in JSON, a grammar is key value pairs. The key is the name of a rule, where the value is an array of options to choose from.
{
“color”:[“blue”,”red”,“purple”]
}
Here we've described a rule color with three potential expansions: blue, red or purple.
Once defined, a rule can be triggered for expansion. Internally this triggering is done by using the rule name in a separate rule but surrounded by # symbols. (Ex: #color#). This expansion means that every rule triggered will be flattened - changing it from a potential choice across multiple options to one singluar option. (Ex: The expansion of #color# could turn into purple.)
Generally, the distribution of probability is even across the options within a rule, but you can reweight them by repeating options. (Ex: Changing color to choose from blue, blue, red, purple would result in blue being chose twice as often as the other colors.)
Also, the 'root' of your grammar is generally expected to be named 'origin'.
{
“color”:[“blue”,”red”,“purple”],
“origin”:[
“I like #color# cake.”,
“I like #color# hats.”
]
}
Here we have our original color rule, but now have our root story node origin that also utilizes that color rule.
If we were to flatten #origin#...
- #origin# is our first expansion.
- #origin# then could be resolved as "I like #color# cake."
- This includes the rule expansion, #color#.
- #color# could then resolve into "purple".
- #origin# becomes "I like purple cake."
From this base understanding you can create much more complicated choice trees by nesting or combining rules.
{
“color”:[“blue”,”red”,“purple”],
“origin”:[
“I #opinion# #obj#.”
],
“feel”:[“dislike”,”like”],
“obj”:[“#color# #thing#”],
“thing”:[“hats”,”cake”,”birds”]
}
Tracery has also been built to include a bunch of language specific modifiers, as creating understandable english prose can be hard if truly including a loosely coupled variance. Examples include things like capitilization, pluralization, addition of an indefinite article etc.
{
“color”:[“blue”,”red”,“purple”],
“origin”:[
“#color.capitalize# #thing.s# are lovely.”
],
“thing”:[“hat”,”cake”,”bird”]
}
#origin# here could become: "Blue birds are lovely" after the modifier applications, even though color's options are all lowercase, and all thing options are singular.
Sometimes though, you want to use a bit of saved state - usually for keeping track of a particular choice for reuse. (#color# expansion chooses a new color every time it's used!). You can instead, however, expand a rule into a new rule definition by using this definition syntax: [ruleName:#expansion#]
{
“color”:[“blue”,”red”,“purple”],
“origin”:[
“[chosenColor:#color#]I like #chosenColor# birds, but not #chosenColor# bananas.”
]
}
#origin# here could become: "I like red birds, but not red bananas." because a color is expanded and stored into chosenColor before the rest of the rule evaluates.
Expansions work from left to right, so make sure to add rule definitions that the rest of your text might require to the beginning of your text expansions, rather than at the end.
Here are some other useful resources to read up on (and try your hand at building) tracery & grammars.
- Editors & Sandboxes
- Tutorials & Reading
- Tracery tutorial by Alison Parrish
- Sculpting Generative Text with Tracery by Andrew Zigler
- Learning Tracery: Part 1: Example and Definitions by Dan Cox
- Learning Tracery: Part 2: Grammars by Dan Cox