I Love Outer Colony Bugs

One of the funnier aspects of developing OC involves the bugs that it produces. By its very nature, almost all gameplay in OC is emergent. This is especially true with NPC behaviors. What NPCs decide to do is the organic result of a dozen subsystems interacting, pushing and pulling at an NPC’s internal decision making process, ultimately resulting in the behavior that we see in the game.

Normally, this is great. It makes the NPCs much more adaptable, and it gives them a mechanism to figure out innovative ways to achieve their goals. It makes the NPCs much more interesting! They’re not just governed by static scripts or finite state machines.

Sometimes, though, this can be a double edged sword. This unconstrained freedom of action can make the NPCs very unpredictable, and their efforts to be very smart can fail in catastrophic and comedic ways. It happens all the time as I test OC, and I’ll get into the reason for it a bit more at the end of this post, but I’ll just walk through one example to demonstrate what I mean.

I was demo’ing OC for a friend of mine the other day, and we were walking through the process of founding a new settlement. Mining, farming, logging, manufacturing, building: everything was proceeding excellently! Then a problem became apparent. All of the NPCs were growing hungry, and none of them were eating food. I figured that some sort of plan generation bug was responsible, as I had been messing around with plan generation shortly beforehand to optimize some aspects of combat. I took a quick look at the plan generator, couldn’t immediately identify the defect, and moved on.

I came back to the matter this morning, founded a new settlement, and tried to reproduce the bug. Sure enough, everyone is standing around on their leisure shift, growing extremely hungry, and refusing to eat the plentiful food in the stockpile just a few tiles away. What the heck is the problem here?!

So I took a look one of the NPCs to try to figure out what her problem was. Enter Klementein Yetir, a fairly normal, 28 year old woman in my Core World expedition. Well, she sure is hungry. That’s for sure:


Hunger is working just fine. Check that off the list. But why isn’t she walking over to the stockpile, getting food, eating it, and sating her need?

Her outrageously funny plan to satisfy her hunger proves insightful:


Her goal is to eat! Quite correct, eating will satisfy hunger. Her plan to achieve this goal, however, is problematic. Klementein has decided to just sit around, crying for food, until someone brings it to her.

At first, this seems stupid. Just walk over and get the food. But when you think about how plan generation works, it becomes clear why she is doing this. An NPC selects the easiest perceived way to achieve the goal. Klementein has weighed her options for getting food, and she’s realized that it’s much less work to just sit around and complain until someone else brings food to her. Indeed, this is less work than walking over to the stockpile and getting food herself!

Klementein thinks she’s being quite clever! And in a way, she is. The problem, though, is that all of the other NPCs have reached the same conclusion. It’s easier to just sit around and cry for food until someone else goes and gets it for them. So what we have is an expedition of layabouts, complaining about how hungry they are, crying for others to bring them food. But nobody’s going to do it! The expedition is locked in a downward spiral of crying, consternation, and laziness. They’re all just going to sit there, arguing and wasting away, until they die.

I find this profoundly funny. On some level, this behavior is insane and undesirable, and adjustments need to be made to prevent it. But what’s wrong with the code? Can I point to the line of code where everything is going haywire? Can I point to the state that shouldn’t be, the algorithm that’s plainly malfunctioning? I can’t, really. This is a sort of meta-bug. An emergent behavior that’s undesirable, but not technically wrong. Each NPC is behaving exactly as intended, making the best decisions it can, according to what it perceives as best.

Ultimately, some sort of common sense (which is notoriously hard to effectively model) will have to be built into OC to prevent this situation from arising. The problem isn’t really rational self interest, which is ultimately driving the laziness. The problem is the failure to assess that nobody is actually going to bring them the food. They’ve all made the assumption that someone else is going to be kind enough to get them the food, because they’re so hungry and are complaining so loudly – but this isn’t going to happen. These sorts of meta-mechanics are inherently harder to control, but it’s just part and parcel of what makes OC’s AI so interesting.

I suppose the point of this article is to demonstrate that, even when NPCs in OC are behaving improperly, it’s a lot of fun for me. I can’t think of many projects I’ve been on where even the bugs have been amusing, and I hope that this sort of strange fun can carry over to release. It’s a part of what makes OC different and special, at least for me.

Posted in Game Design, NPCs