Notes on Practical Procedural Generation
Overview
Here are some notes I took while watching Kate Compton’s talk covering practical procedural generation techniques.
Examples
- Made a system that could generate game rules
- Made a player that could play arbitrary games
- Had virtual players play thousands of games, until he found a game that was pretty well balanced
It is as if you were playing chess
Fitzwilliam Darcy’s Dance Challenge
The Treachery of Sanctuary - CHRIS MILK
Toca Hair Salon - The Power of Play - Toca Boca
- Lots of generative content uses extremely sophisticated and brilliant AI and fails anyway
- Some of the best generative content is simple
- The hardest part of procedural content is design
Steps
- Understand the design space
- Enumerate your constraints
- Understand the process
- Pick a generative method
- Iterate and be flexible
- A lot of great generative projects are things that were tried because it is a stupid idea
What are you making?
- Be specific
- Level generator
- Character creator
- Abstract art generator
- cocktail recipe generator
- game title generator
- conversational character
- poetry generator
- twitterbot
Making an artist-in-a-box
- teaching an algorithm to make art like an artist
- Find and expert (or read their writing)
- How do they think through a problem?
- Example Question: “If you are designing a creature, what do you do?”
- Example Answer: They start by drawing a bean shape as a base for the creature, and hangs a mouth on it.
Additive and Subtractive Methods
- Build up a space of good stuff
- (optional) Remove bad stuff
- Vocab:
- Possibility space
- Expressive range
The IKEA Catalog of Generativity
- A catalog of generative methods and why you might chose each
Additive Methods
Tiles
- Works well for
- Something you can break into (equal-sized) regions
- where tile-to-tile placement don’t need to be constrained
- Can use WaveFunctionCollapse when placement needs to be constrained
- but you can still get emergence from the placement of tiles
- one of the oldest forms
Grammars
Recursively make things from other things
Tracery and other templating systems (for text)
L-Systems (for geometry)
Replacement grammars
Distribution
- put down a bunch of stuff
- can use random numbers (actual randomness does not look good)
- real distributions are hierarchical and clustered, but also maintain spacing
- Barnacling: when you have a large object in your world, there should be medium sized objects around it and smaller objects around those
- Footing: When two things intersect, there should be an awareness of them intersecting
- Example: If you stick tree in the ground, there will be dirt piled up around it
- Greebling: cosmetic detailing added to the surface of an larger object that makes it appear more complex or technologically advanced
- Options
- start with a grid, and offset a bit
- (less obvious with a hex grid)
- Use a voronoi diagram with easing
- Do it properly with a Halton Sequence
- start with a grid, and offset a bit
Parametric
- An array of floats representing settings, “morph handles”
- modellable as points in an N-dimensional cube
- Any position is a valid artifact
- You can do genetic algorithms
- or use directed walks through the space
- or “regionize” the space
Interpretive
- Start with an input
- Run an algorithm to process data into some other data
- You have a simple structure
- some distribution of points, a skeleton, a connectivity map, a curve or path and want to make it more complex
- Examples:
- Noise (Perlin/simplex)
- Voronoi/Delaunay
- Constructive Solid Geometry Extrusion, revolution
- Metaballs
- Fractals, mathematical models of impossible shapes
- (Hypernom, Miegakure)
- low control, high weirdness, not suitable for most games
Simulations
- Particle trails
- simulate particle path responding to forces
- draw directly
- OR record path and use for extrusions or distributions (Photoshop brushes)
- Goes great with user input (Leapmotion, Kinect)
- Cellular automata
- Agent-based simulations
- Physics simulation
Subtractive Methods
Saving Seeds
- Seeded random numbers
- Same seed, same random generation
- Make sure nothing is framerate or input dependent
- Same seed, same random generation
- Whitelist a catalog of known good content
- It’s faster to verify questionable content than to build a testing function
Generate and test
- If you can write an algorithm to judge “quality”
- Throwaway vs ranking/prioritization
- Use ranking/prioritization
- Test for brokenness/connectivity
- Throwaway vs ranking/prioritization
- Beware of false functions
- beware the “fun equation”
Computationally exploring the possibility space
- Also called “search”
- Brute force search
- “Find the tallest creature that the tool can make”
- “Make a level that has these properties”
- Hill-climbing
- Genetic algorithms
- Works best with parametric methods
- Brute force search
Constraint-solving
- You can describe a possibility space and constraints, just find the valid parameters.
- Inverse Kinematics-solving
- Answer set solving
- Potassco Clingo
- DO NOT WRITE YOUR OWN SOLVER
- Brute force
- pay attention to exponential growth
Making use of Generativity
- You can generate many things
- They are all mathematically unique
- But they aren’t perceived as unique
- Is this a problem?
- Do not boast about really big numbers
Different kinds of generative content
- Background
- In-fill (don’t be empty)
- Perceptual differentiation
- Perceptual uniqueness
- Characterful
- Test: Would you write a fanfic for this generated item?
Ownership: MSG for PCG
- Allow users to name content
- Showing off content with their name attached, to a large audience
- The “victoriain explorers club” model
- promote players
- Let players take credit for your generativity
- creators, curators, retellers
Data Structures: Make your life easier
- A/B test generators
- Release new generative content safely
- Create editors and run user-made generators safely
- Visualize your generators
Further Reading
Danesh: A tool to help people explore, explain and experiment with procedural generators
References:
I’m Christian Mills, a deep learning consultant specializing in practical AI implementations. I help clients leverage cutting-edge AI technologies to solve real-world problems.
Interested in working together? Fill out my Quick AI Project Assessment form or learn more about me.