# World map, approach 2: Voronoi polygons Open `index.html?seed=7&style=polygons` (styles: parchment, painted, hex, iso, polygons). ## How it works In the spirit of Martin O'Leary's fantasy maps and Azgaar's generator: 1. 2400 jittered points, a **Bowyer-Watson Delaunay** triangulation (own code, naive O(n^2), about 100 ms), Voronoi cells from the triangle circumcentres, one **Lloyd relaxation**, triangulate again. 2. **Elevation per polygon**: a random tilt, 7 random hills, one chain of small cones (a mountain range), fbm noise and a noisy radial falloff. 3. **Erosion-ish**: four rounds of depression fill on the polygon graph, flux accumulation, erosion proportional to sqrt(flux) x slope, and neighbour smoothing. 4. **Rivers** follow the drainage tree from polygon centre to polygon centre (that is, along the Delaunay edges; O'Leary routes along Voronoi edges, which looks a bit more natural). 5. **Cities on polygons** with the same scoring as approach 1; ruins and dungeons in wild polygons; natural features as connected polygon regions. 6. **Roads**: A* on the polygon graph (cost by biome, height difference, river crossing, existing road discount), smoothed with Chaikin. 7. The mesh is then **rasterised** to the same 240x160 heightfield (barycentric elevation, nearest-polygon biome), so all shared styles and the JSON shape work unchanged. ## Good - Very fast: 2400 nodes instead of 38,400 cells; A* and erosion are cheap. - The polygon look (style "polygons") is a recognisable, readable map style on its own. - The polygon graph is a natural fit for "regions": a kingdom or a forest can be a set of polygons. ## Bad - More code for the same result: Delaunay, Voronoi cells, Lloyd and rasterisation before any geography happens. - Biomes come out blocky (one biome per polygon), visible in the painted style. - Rivers and roads zig-zag between polygon centres unless smoothed; coastlines show the polygon scale. - The island shape is dominated by the falloff: worlds look alike across seeds unless the blob layout is made more varied. ## What it costs to make real - Same choice as approach 1: run in the browser and post JSON (1-2 evenings), or port to PHP (3-4 evenings, the Delaunay is the fiddly part; a library would help). - Robustness work: the naive Bowyer-Watson is fine at 2400 points, too slow at 20,000. ## How it fits the locations tree Identical to approach 1: the world row holds the rasterised heightfield in `representation_data` (with a note that the mesh regenerates from the seed), children carry `map_x/map_y` in cells, `location_edges` carry `travel_cost` (hours on foot), `path_kind` and `curve`. If regions become important, the polygon ids per region could be stored too. ## How the AI world-builder would use it Same as approach 1. Constraints are easy to express as elevation blobs placed by the AI ("a mountain range from here to there" becomes a chain of cones, which this generator already uses), and polygons make "this region belongs to the kingdom of X" natural.