promptsandmore.com

Click. Tweak. Observe. Understand.

Spatial Partitioning

Voronoi diagrams, Delaunay triangulation, and Lloyd relaxation

System Overview

Voronoi diagrams partition space into regions based on distance to seed points. Each region contains all points closer to its seed than any other. Delaunay triangulation is the dual graph of Voronoi, connecting points whose regions share boundaries.

Lloyd relaxation iteratively moves seed points to their Voronoi cell centroids, creating more uniform, evenly-spaced partitions. This is essential for biome generation, territory mapping, and procedural world division.

Why Games Use This

Key Parameters

Failure Modes

Scaling Behavior

Naive Voronoi computation is O(n²) per cell. Efficient algorithms (Fortune's sweep) achieve O(n log n), but for real-time applications, limit to 50-100 points. Lloyd relaxation multiplies cost by iteration count.

For large worlds, use hierarchical approaches: generate Voronoi at multiple scales, or use spatial hashing to only compute nearby regions.

Related Algorithms

Free Tools & Libraries

System-Thinking Prompts