Random numbers are more “clumpy” than what people expect. The polygon shapes and sizes are a bit irregular.
Here’s an example of random dots (red) and the polygons that result: I’m using nodename’s as3delaunay library, which has an implementation of Fortune’s Algorithm. The Voronoi wiki is incomplete but has some useful background.
This works (and the techniques on this page will work if you use a perturbed grid), but I wanted something even less regular than that, so I picked random points and generated Voronoi polygons, which are used for lots of things, including maps. The simplest approach would be to use a hexagonal grid and perturb it a bit to make it look irregular. The first step is to generate some polygons.
#GAME MAKER STUDIO PROCEDURAL GENERATION GENERATOR#
Each of the ideas on this page can be used separately or together in your own map generator project. When writing your own map generator, think about what which aspects of your map are set by the design and which can vary from map to map. In multiplayer Age of Empires, the location of resources is constrained by the need to be somewhat balanced among the players in Minecraft the distribution of resources is not constrained. Elevation in Minecraft on the other hand isn’t constrained the same way, so the noise function they use works for that game. Elevation directly corresponds to difficulty, and must monotonically increase, so that was a key constraint in the design. For this project, the gameplay constraints were partially taken from Realm of the Mad God, a multiplayer RPG in which players start on the beach playing alone and then later join together on the mountaintop to fight bosses. Here’s the overview of the process:Įvery project will have its own gameplay constraints. Read on to learn how it works, or get the source code. For the rivers, I started with something simple: draw rivers from the coast to the mountains, so that you can always follow rivers down to the beach.įirst, try the Flash demo (2010) or an HTML5 demo (2017). For the mountains, I started with something simple: mountains are whatever’s farthest from the coastline, so that you can always walk uphill to reach the top. For the coastline, I wanted to make island maps that are surrounded by ocean, so that I don’t have to deal with people walking to the edge of the map. There were three main things I wanted for this project: good coastlines, mountains, and rivers. Instead, I used a graph structure to model the things directed by gameplay constraints (elevation, roads, river flow, quest locations, monster types) and noise functions to model the variety not constrained by gameplay (coastline shape, river placement, tree placement). Most procedural map generators, including some of my own previous projects, use noise functions (simplex noise, midpoint displacement, fractal, diamond-square, perlin noise, etc.) to generate a height map. I generated maps with polygons, then rasterized them into tile maps that looked like this: What could I do with 1,000 polygons instead of 1,000,000 tiles? The distinct player-recognizable areas might be useful for gameplay: locations of towns, places to quest, territory to conquer or settle, landmarks, pathfinding waypoints, difficulty zones, etc. I usually make tile maps but instead used a different structure. I wanted to generate interesting game maps that weren’t constrained to be realistic, and I wanted to try some techniques I hadn’t tried before.