After working on getting characters moving around the area map, where the map consisted of a literally random scattering of walls, I thought it was time to make a start on actual maps for use as game areas, and so this has been the focus of July's development effort.
Following on from some work I've done previously with procedural generation, I decided I wanted to use midpoint displacement, aka the diamond square algorithm, to generate some random heightmaps to use as the basis for a 2d representation of the playable area in and around a mountain.
I wanted to use this rather than some noise algorithm like perlin or simplex noise as midpoint displacement is a fractal algorithm, and fractals tend to appear more natural and less random to the human eye, as fractals are everywhere in nature.
From this heightmap, which must be square due to the algorithm, it is cropped to the desired size and a height is picked at which a certain amount of the map is above, and the rest is below. Currently it's a 50/50 split of mountain and outdoor area, though this will likely end up configurable on game start. Also for the examples on this page, I've used a square map size (although it is smaller than the heightmap generated, so it has been cropped to the middle area).
The trickiest and most interesting step to get right is in generating a set of caves inside the mountain. Not so few that they're all small or too spaced out, but also not so numerous that there's not enough rock left in the mountain for the player to use or so large that the player is constrained into playing within the caves generated rather than carving out their own personal fortress. The algorithm in this step uses a mix of simplex noise combined with the original heightmap to favour larger cave systems deeper inside the mountain (though there's often an entrance to the outside).
These areas (and the gradient of the outside land in shades of green), so following Michael Cook's article of Cave Generation using Cellular Automata, I used the algorithm described to smooth off the edges of the mountain, caves and outdoor regions.
This gives a much more organic and natural look to the areas produced, compared to what would have appeared to rough and random in-game.
Next I wanted something to place resources such as gold, coal and iron ore in a vein-like layout, and I'm happy with what I came up with after some thought on the subject. Similarly I came up with a few algorithms to place trees within the darkest regions of the outside, and ran a river across the length of the map using A* pathfinding and the original heightmap values. At this stage everything should be treated as a work in progress and open to improvement later but I think it should suffice for now.
In terms of other updates this month, Dave Rigley has done further work on the in-game dwarf characters featured last time as we get a better understanding of how the assets and game engine should work together. We now have a base set of body shapes for both male and female dwarves:
Last but definitely not least, Anthony Avon who created the wonderful dwarven settlement concept art featured last month, has been working on a set of dwarf character designs to fit into the same world.
These represent the different jobs and professions currently planned for dwarves in King under the Mountain (though I'm sure there's a good chance the list will grow in the future!). The focus for the next month is going to be working on a tool or set of tools to help get these characters into the game, and in the future, enable modders to enhance these or add their own creations!