Map generation stress test
For this week's update, the focus was stress-testing. It's a quick re-do of some older approach, but a bit more ... stressful. I wrote now some code that generates a dungeon specification procedurally, with some basic rules, which mostly are:
- Choose a layout between cavern/dungeon/coast, sized 160x90 or 80x45 (for 16:9 aspect ratio purposes)
- For that layout, parameterize it randomly (for all its parameters except child zones)
- If this layout is not a prefab, place a number of child layouts, depending on the containing zone area. For each, go to step 1 with reduced dimensions and allow selecting prefabs
Now this very simple specification can create very very complex maps, when the RNG stars align. It also fails because occasionally some settings might end up being problematic. I wanted to generate a nice 1 hour video that demonstrates such maps, so I planned for 3500 images, requested the system to generate 5000, and it generated 3851 successfully, which was pretty close to my estimate. The number of prefabs and sparse feature configurations are pretty scant, but fine for now. Here's the resulting video:
While preparing for the stress test, lots of things were changed, naturally, in the generator code, such as:
- General bug fixing, manifesting as failed connections in some cases
- Export generation configuration to JSON, allowing easy recreation of any map, and can be used for problem-solving bad maps.
- Support for flooded areas. Rivers and lakes are generated in maps, and sometimes they overlap with rooms. Rooms have a "flooding percent" parameter which dictates how much water will be left in that room. Currently, water tiles are removed randomly but in the future the shapes might need to be blobbier/nicer
- Inner zones can have open spaces at map borders, we just don't spawn exits there. This means that e.g. you can walk left in an embedded zone and you might hit the end of the map on an open floor, and that's ok. I didn't enforce bounding it with rock or whatever, because if rocks can become destructible with skills/spells, we still end up with a floor at the map border that leads nowhere. That's ok! It's a game, not a continuous world simulator.
- I just realised that if I create a coastal map and disable the "open borders" option, the map becomes an island map, surrounded by water. Hmmm, cool! It doesn't look too blobby, but that's an exercise for a different time
- Sometimes zone-zone connections were too many too close together. Now there's a test that prevents that.
- Dungeon maps, if I didn't specify any prefab rooms, became proper maze maps. While that's cool, I do want the option to generate a dungeon with no rooms, which is a big empty area, so I've fixed that
Prison layout: warden office
I've added support for multiple room prefabs for "prison" layout: one default and some other special ones with placement number constraints. So, a prison can specify a basic cell as the default, and one warden's office as a special room that HAS to be placed. Done!
Next week: minecart tracks and altars