Holes and Paths
The new jaggy room shapes sometimes include holes. Makes me think about secret rooms. And, not unrelatedly, about paths. Just thinking, and an interesting experiment.
When set to always prefer the previously used cell, the experimental room maker sometimes leaves very interesting “holes” in the middle of rooms:

That got me thinking about secret rooms within rooms. A hole in a room would always show up as a walled space that you could walk around. It might be a small square column, taking up one tile, or, as in the map above, it could be larger, with an interesting shape. In a game, if this ever were to turn into a game, such a space might occasionally include a door, possibly a secret door, and it might hide something interesting inside, such as treasure, a huge crowd of monsters, or a boss of some kind.
Detecting Holes
That line of thought can quickly turn into a number of lines, one of which I don’t know how to solve: how can we detect a hole that is completely interior to a room? It seems to me that it isn’t simple. For example, we can’t just say something like “a hole is an unallocated cell or cells such that when you travel in any direction from it, you encounter a cell from the same room, which is the room containing a hole.” I’m imagining a sort of spiral room, and asking whether the open cell in the center is a hole.
Hmm … what if we were to pick an open cell and flood fill, selecting unused, and returning the cells that stopped the fill. If all those cells are cells of the same room, does that tell us that the cells flooded are inside that room? I think perhaps that would work.
OK, maybe I do know how to identify a hole, at some cost. We could probably write some tests for that, try the idea.
Creating Inner Rooms
A simpler issue that came to mind was making room builders that intentionally build holes or inner rooms. Imagine that we build a round room, and then, arrayed around the center, we place some number of equally spaced single tile holes / rooms. Viewed from the inside, we’ve have a big round room with columns around a central area. Very tempting to go in there, isn’t it …
It seems pretty straightforward, given a room, to place a hole of any reasonable shape inside it, programmatically. Just have to make sure there’s enough space for the inner room, the rest would just be replacing the room field in those cells with the new room.
Paths
One of my concerns with paths between rooms is that as presently coded they are often long narrow hallways with a single turn from straight across to straight down. At one point I had them trying to go diagonally, but that wasn’t really much better.
When we look at the picture above with paths in mind, we see three “suites”, and they are very close to being connected. In each case, we can see where just a few more steps would do the job of connecting them all, which is what we want: there has to be a way to get from any room to any other, so all the suites need to connect.
I just tried something.
I set the room size to be randomly between 100 and 200 cells, and the probability of trying the previously used growth cell at 1, that is, always try to grow from where you just grew. Some results are shown below. It appears that more than half the time, we got a fully-connected set of suites. But not always.
Connected:



Not Connected:

That last one is so close, but not quite: a diagonal touch between rooms doesn’t leave room for a door, so the lower bit, including the diagonal down and to the left, isn’t connected to the top bit.
Anyway …
As close to good as this is for a cavern, we want to be able to support other kinds of layouts such as a rectangular castle kind of thing or a sort of village arrangement or whatever we might come up with, so I think we’ll have to be able to create paths between suites, and perhaps even to control what kind we want, straight lines where possible, and so on.
Summary
I think I slept with one eye open last night, so I’ll cut this short before I succumb to eyeball irritation, which would be a really embarrassing way to die. I have some tentative decisions based on the morning:
- Explore finding holes using flooding and checking end conditions.
- Research the topic of finding holes on the Internet, avoiding hives of scum and villainy.
- Think about whether paths could be grown, using logic similar to what is running now in the experimental room, with some kind of tendency to go in a particular direction.
- Think about finding the cells of two rooms that are closest to each other, as candidates for connecting them together.
- Think about whatever those things bring up …
What is fun, for me, in things like this, is that developing the code becomes not so much a work task, as a creative session of interesting notions and discoveries, together with the pleasure of getting the computer to do what one had in mind.
I hope whatever you spend your time doing brings you pleasure. We need bits of joy in these parlous times.
See you next time!