The one thing that CivClicker lacked was any sense of how your civilisation fit into the world. For the new version, I want the player to get closer to the original Civilization experience and build cities and units on a world map.

Of course, that map doesn't just come from nowhere.

After doing some fiddling I decided to take a leaf out of Notch's book, and use a noise function to build my maps. Perlin noise gives a smooth but random distribution across a given coordinate space (in my case, 2D), making it ideal for generating things like heightmaps.

Getting the first map working was as simple as coding up a grid system, assigning heights to the grid nodes by running their coordinates through a noise function, and then defining a sea level. It was then fairly easy to assign terrain types based on height (below sea level: ocean. above mountain level: mountains. in between: grassland). The picture for this post takes this a step further by randomly determining whether the lowlands are grass or forest based on another noise function.

The next step was to come up with something that looked a bit more earthlike, and had a bit more variation. I wanted different tiles that meant it mattered where you placed. Continuing to steal from Notch I decided that I'd implement a biome system (using this graph that you may have seen if you followed Minecraft's development) and lay that on top of the heightmap.

Biomes required two further sets of data: temperature and precipitation. They still needed to be noisy, but for the eventual biomes to be distributed in a fairly Earthlike fashion, they to needed to be fairly Earthlike in their distributions. In the end I built them both from cosine graphs scaled appropriately and more noise.

The result is what I'm working with now. It probably still needs tweaking (for instance, I've yet to see a swamp anywhere) but it's working well enough for the moment. Time to move on to the next thing.