Hey Patrons, in this weekly I’m going to share some early progress and experimentation on level generation for the blacksmith quest!
Also, next week’s weekly will have an audio Q&A segment! Feel free to ask questions either here or on the Patreon discord.
As mentioned in a previous weekly, I plan for there to be ~40 gold ore to find in the blacksmith area, arranged into small and large clusters for the player to mine. The current gold generation algorithm is a fair bit more random than that though. It simply takes every camera-facing wall tile and has a ¼ chance of turning it into a gold tile. This is pretty decent for evenly distributing gold, but does not cluster it at all and makes no guarantees about how much gold is actually in a level.
The game already has a system for clustering terrain though, called the ‘patch’ system. The game currently uses it for water, grass, and for rooms that have a less structured appearance. This system does a decent job of creating random clusters of terrain, so I applied it to the mining level with a little twist: generated gold only actually gets filled in if it is on an external wall tile, or next to a gold cell that is on an external wall tile.
This way gold clusters don’t get too big and are always visible on the surface of walls. The game keeps trying to place gold in passes until there are 42-46 gold cells total. Here’s an example of how that looks, with barricades used instead of gold, for better visibility:

The big problem at the moment is that while this system guarantees a certain amount of gold and clusters pretty well, it gives no guarantees about how evenly the gold is spread overall, which can lead to generation like this:

Clearly there’s more work to do here, but the patch system is pretty customizable, and this may become less of a problem as more aspects of the mining level are pinned down. For now I’m calling this ‘good enough’, and plan to re-visit it after more aspects of levelgen are pinned down.
Speaking of the patch system, it’s actually what the entire mining test level currently uses! The existing level is basically one giant cave room, with the requirement for all cells to be connected to each other turned off. This is great as a quick little test but is far too predictable (static level size and entrance position) and also too random (no guarantees at all about level contents) to use for the quest proper.
As an initial test, I’ve swapped to a system that uses a bunch of smaller cave rooms, one entrance room, no tunnel rooms, and a level builder that’s more chaotic and random than normal. Most levels use a core structure of a loop or figure-eight, and then place a few random branches after that. At the moment this builder just places two rooms off the entrance as the core, and it’s all branches from there. Doors are all removed, and a couple rooms are forced to be hidden.

This is, once again, a pretty good starting point. We have some guarantees about how many rooms are in a level, the shape is usually pretty condensed, hidden rooms are always next to visible ones (and not way off into the wall), and despite this the level feels more chaotic and random than before.

Still, not all the random shapes are winners, and the overall structure is pretty open for a level the player is meant to be able to mine though.

Now that I have a decent starting point, I plan to start pinning down specifics about how the individual rooms of the quest area may be structured. This mainly includes things like quest hazards and objectives. Hopefully I’ll have a bunch of details to share on that next week.