Skip to content
ExtendedSource checked

Shape Grammar Generation

Generates geometry by repeatedly applying spatial rewrite rules to shapes.

Quick Facts

Compact metadata for implementation and discovery.

Category
Procedural Generation
Difficulty
Advanced
Family
Grammar-Based Generation
Tier
Extended
Status
Verified
Review
Source Checked
Sources
2
Formulas
1
Relationships
3
Code example
Ready
Visualization
Ready

Overview

Shape grammar generation treats geometric elements as symbols and applies rules that split, replace, or decorate them.

Core Concepts

shape rulespatial rewritederivation treegeometric constraint

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(output size)

Average

O(output size)

Worst

O(output size)

Space

O(output size)

When to Use

  • Use when generating terrain needs shape rule.
  • Use when the input matches the assumptions behind grammar-Based Generation.

When Not to Use

  • Avoid when the design needs strict authored control over every generated detail.
  • Avoid when a simpler algorithm gives the required result with less setup.

What It Does

  • Generates geometry by repeatedly applying spatial rewrite rules to shapes
  • Uses shape rule and spatial rewrite to guide the work.
  • Produces generated map, texture, layout, or pattern.

Use Cases

  • Generating terrain
  • Creating textures
  • Building levels or natural patterns

Inputs

  • Seed
  • Generation parameters
  • Constraint rules

Outputs

  • Generated map, texture, layout, or pattern

Key Formulas (1)

Shape rewrite

shape → transformed subshapes
shape -> transformed subshapes

Expands one geometric element into a structured arrangement.

Pseudocode

  1. 1.Prepare the inputs and state needed for Shape Grammar Generation.
  2. 2.Apply the shape rule step while the stopping condition has not been met.
  3. 3.Update intermediate state and discard invalid candidates.
  4. 4.Return generated map, texture, layout, or pattern.

Canonical Example

Input
Shape Grammar Generation input with a small representative case
Output
Generated map, texture, layout, or pattern
Explanation
Shape Grammar Generation applies shape rule to produce generated map, texture, layout, or pattern.

Implementation Notes

  • Keep the seed and parameters stored with generated output for reproducibility.
  • Keep the shape rule step separate enough to test independently.

Common Pitfalls

  • Small parameter changes can create large visual or structural differences.
  • Forgetting to check edge cases can make Shape Grammar Generation look correct on only ideal inputs.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show the generation state evolving from seed values to the final artifact.

Shape Grammar Generation mechanism walkthrough step 1 of 4
Step 1 of 4: Prepare the inputs and state needed for Shape Grammar Generation.
procedural-generation-mechanism

Notes

Shape Grammar Generation should be used with the assumptions and tradeoffs of grammar-Based Generation in mind.

Sources (2)

What each reference supports for this entry.

Procedural Content Generation in Games

Book

Procedural-generation reference for rule-based spatial grammars and constructive content generation.

Open source

Introduction to Shape and Shape Grammars

Paper

Reference for shape grammar formalisms and recursive spatial rule generation.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Both can generate structured spatial layouts.

Shape grammars specialize grammar rules for spatial structures.

Tags

Procedural GenerationGrammar GenerationGeometryGeneration