[Home] [Buy] [News] [Family Trees] [Leaderboard]
[Photos] [Update Log] [Forums] [Unicode Language Mod] [Tech Tree]
Update: Curved Tracks
January 24, 2020

https://i.imgur.com/NA9DVDT.png

Forum member Wuatduhf made an important discovery: recent changes to the way object patterns work had suddenly made curved cart tracks much more reasonable to implement.

It turns out that I already had the graphics drawn for these curves, and they looked really good back in the day, but I had to scrap them because of the combinatorial explosion that they would entail. For example, north-moving carts already had three "leave" cases (leaving from south ends, north-south tracks, and cross tracks) and three "entering" cases (entering north-south segments, entering north ends, and entering cross tracks). To handle all the combinations, 9 distinct transitions were required for each cart direction, resulting in a total of 36 transitions. That's a lot, but as soon as we add in curves, it blows up even more, with something like 25 transitions needed for each cart direction, or 100 total. That's a lot of transitions to author correctly, and way too much to keep track of along the way, resulting in tons of room for error.

So what changed with object patterns to help with this problem? Something pretty tiny and simple, actually. Part of the bottle update a few weeks back involved emptied bottles that made a final sound as they were emptied. Roughly half of the bottles held liquid, and the other half powders, requiring a different empty bottle state for each to play the "glug-glug" or "swish-swish" sound. All the bottles were part of one big 18-item pattern, but how could I flesh out the empty state for this pattern? Since an object can only occur in a given pattern once, I would need to create 18 separate "empty" bottles, even though they all pretty much did the same thing (half of them playing the powder sound instead of the liquid sound). That's a lot of extra objects that essentially do nothing. But why couldn't a pattern have repeated objects in it? In other words, why couldn't a pattern "converge" on a few common end states? These bottles could be different all along, with 18 variations, but once empty, end up as one of two empty-state bottles to play one of two sounds. Each of the 18 slots in the pattern would contain one or the other of these two bottle objects. I updated the pattern editor to support this, and that was it.

Wuatduhf's observation was that these new "converging" patterns were exactly what was needed to cut through the combinatorial explosion for tracks. As a simple example, when a track cart moves north out of one of five possible north-bound tracks, each of these needs to potentially land in the same connecting track. This can be implemented as a pattern, then, only if the pattern can contain repeats of the same destination track.

Thus, instead of 25 separate north-bound transitions, I was able to implement one set of north-bound transitions describing what happened to a north-bound pattern, and then fill the pattern with all the cases.

This also allowed me to implement tracks that pass through spring-loaded doors pretty easily, preserving the insulation bonus for the room that the track emerges from.

In the end, each of these patterns had 25 elements each (with repeats to cover the various combinations), and the north-south patterns had 36 elements each (due to the extra combinations needed for passing through spring doors). And there were five separate patterns for each direction, resulting in a grand total of 610 items listed in these patterns (all passing through only a small handful of transitions).

There was still a lot to keep track of when fleshing out these patterns, and the whole thing felt about as close to an IQ test as I've experienced while working on this game. My moth-holed, 42-year-old brain muddled through it all, but barely.

But those curvy tracks sure do look nice. Great to dust off 17-month-old artwork and finally put it to use.
[Link][4 Comments]






[Home] [Buy] [Wiki] [Food Stats] [Fail Stats] [Polls] [FAQ] [Artwork] [Credits]