It's alive! It's aliiiivve!

DT: Better Building Through Science!

Hey everyone,

Stephanie is currently enjoying the last of her well-earned vacation, so I (Chris) am here to fill in for Desktop Tuesday this week with some updates on what I’ve been doing.

One of the things I’ve been looking at recently is fixing our building system.  Right now, it’s really easy to design a building that will cause your hearthlings to throw up their little hands and shout “nope” at the top of their lungs (which, come to think of it, would be a pretty cool little effect to see in the game).  There’s even a mega-thread we set up in the discourse where you can upload links to your unbuildable building templates.

The good news is that many of these buildings now build (on my computer, anyway :))  There’s still lots of work left to do until we have something that’s both user-friendly and powerful, but Alpha 15 should be much much better for all the aspiring architects out there playing Stonehearth.

I’m going to actually describe a few of the various difficulties some of the more advanced buildings out there have presented, as well as our solutions to these problems. This’ll be a little more technical than a typical Desktop Tuesday, but that’s what Stephanie gets for inviting me to write 🙂

The first thing to understand is the basic flow for building.  The way hearthlings try to build a building in Alpha 14 is in a sensible way: start with the foundation, build out ground-floor walls and columns, and then start building upper levels, in the same way.  In particular, they’re trying to make sure that all the structure dependencies for a given building part are satisfied, before starting to build that thing.  For example, an upper floor will depend on the walls and columns directly beneath it.  

Here, the floor, outlined in green, must be built before the walls and columns, outlined in red, which must be built before the roof, outlined in blue.

This generally works well for simple structures, but things start to get difficult when players start challenging some of our assumptions.

Nope.
NOPE.

This will look maddeningly familiar to anyone who does any advanced building.  This will not build!  But why?  The problem is that the stairs touch the lower floor, and the upper floor.  What ends up happening is that both floors and stairs are fused into a single object, which the hearthlings then try to build, all at once.  They cannot, though, because the dependency system in Alpha 14 thinks that the first-floor walls depend on that object (because the walls are on the floor) and that the object depends on the walls (because the second floor rests on the walls).  A depends on B, which depends on A–a cyclic dependency has formed!  This is bad, because it means the hearthlings can’t start A until B is done, but cannot start B until A is done.

The solution we’re using in Alpha 15 is remarkably simple (it also seems to work well!).  We split these large floor objects by the ‘story’ they occupy, so that the part of the floor that is on the second story is a separate object than the part that is below.  As you can see below, the lower floor and stairs are built first, before the upper floor is constructed.

Build the lower floor first? Yeah, that makes sense!
Build the lower floor first? Yeah, that makes sense!

Another major issue we ran into with complex buildings had to do with multi-story scaffolding.  Hearthlings have to put up scaffolding around in-progress structures so that they can build the tops of those structures.  Presently, when deciding where to put scaffolding, we try to find a solid base for that scaffolding by examining the area around the structure.  For bottom-floor walls, this is simple (just put it on the ground), and for simple upper-floor walls, we will pick the inside of the building (because the floor has already been built, and so it can support our scaffolding).  This is what is happening in the image below.

Sometimes, scaffolding is an inside job.
Sometimes, scaffolding needs to be an inside job.

Scaffolding needs to have a clear path to the top of the structure being built–if not, hearthlings won’t be able to build everything they need.  For example, in the image below, a wall has some decorative voxels attached to it, which means that the scaffolding has to go on the other side of the wall, so that it doesn’t get in the way of those voxels.

Hearthlings afraid of heights?
I don’t want to climb out there. Hey, Mer! You want to climb out there?

So, if you combine some decorative voxels getting in the way of normal scaffolding placement, with walls on second-stories, you can wind up with some impossible-to-build buildings.  We can’t place the scaffolding on the outside because there’s no base, and we can’t place the scaffolding on the inside because there are voxels in the way.

The solution is to see if we can reuse lower-story scaffolding.  This works really well in practice, and has the added benefit that we don’t have to keep constructing additional scaffolding.

It's alive! It's aliiiivve!
It’s alive! It’s aliiiivve! (Insert maniacal building cackle here.)

These are some of the major issues players have been running into with building that we’re tackling, and we hope to have many more working by the time A15 goes out the door.  Personally, I’d like to thank all the fine folks that have contributed to the impossible-to-build thread on the discourse; this has made finding and fixing these issues dramatically easier than it would otherwise have been.

Look for this improved building goodness in Alpha 15 (coming soon to a computer near you).