CanaDan, and Condition System Refactor

Alors, c'est officiel! Je suis un citoyen canadien!

IMAGE( Also in attendance: one Canadian Mountie and Wilson Fisk.

I was a bit secretive about yesterday's day off, but it was because I didn't want to announce anything in case my citizenship test had any problems. Thankfully, there were none, and as of 15:00 yesterday, I was officially granted citizenship! Many years in the making, I'm glad to finally have it completed and be a member of a country with some very cool values, and home to my wife's family.

Back in the office this morning, I resumed work on my sleeping simulation. It was almost working as designed, but it still had some issues. One major issue involved negative sleep and comfort stats causing problems with the sleep cycle trigger. And I wasn't able to stop the stats from decreasing when below 0.

Part of the problem was that it was becoming hard to keep track of trigger thresholds the way I had them setup. I basically had one threshold per trigger, with a parameter to control whether that threshold triggered if the stat crossed it in the "up," "down," or "both" directions. This worked pretty well for situations where I needed a condition above a certain threshold. (E.g. comfortable when the comfort stat is above 8, say.)

But it became unwieldy if I had NEO-Scavenger-like stats that had different conditions at different levels. E.g. well-rested becomes tired at 16, drowsy at 24, weary at 48, and blacking-out at 72. With a single threshold value, I basically needed two triggers per tiredness state: one to add the condition when crossing the low threshold and one to remove it again when crossing the next trigger's threshold.

I started to realize that it would be easier to understand and maintain if each trigger just had a minimum and maximum threshold to control when it fires. "Tired" could simply be active from 16-24 hours of sleeplessness, and one trigger both adds and removes that condition as the sleep stat increases. This also lets me have +/- infinity as thresholds, for things with no upper or lower limits.

So most of this afternoon was spent refactoring the condition system to use these min/max thresholds instead of threshold+direction. There were some bugs that needed sorting out, but it's working well now, and using less data than the previous system.

My AI would sleep when tired, and (usually) stay asleep until completely refreshed. It would even tend to fall asleep again the next day around a similar time. If it had multiple days without sleep, the sleep cycle would be longer (9-12 hours) and may not completely refresh the AI, but it'd be able to stay awake again long enough to get back into a rhythm.

And most importantly, it's easier to understand from a modding/data-entry point of view.

This turned out to be a good test for the prototype, as it exposed a weakness in the design, allowing me to iterate on it and improve it. I think I'll try adding one more system (hunger/food) to the prototype, to see if it exposes any other issues. Since it'll likely use a second ship-board item (fridge), it'll dovetail into one of the next tasks I need to tackle: formalizing the item system so it is data-driven and modular.

It might also be interesting to ramp-up the prototype to multiple AIs again, to see how their sleep and hunger interplays with the social sim. Lots of neat stuff on the horizon!


linibot's picture

Congratulations Dan. :) I am intimately familiar with the long and complicated processes of visas and citizenship applications, so I can appreciate the celebratory feeling of finally getting done with it. I hope you had a couple of cold beers in the party afterwards!

NEO Scavenger: FAQ
10 Ways (not) to Die - A beginner's guide

Kaaven's picture

Congratz! Now you are officially half-way to becoming British...

<--Mighty (mini)Mod of Doom-->
DeviantArt Gallery of MoD Sprites

dcfedor's picture

Thanks guys!

@linibot, indeed it was a process! It felt like half of the test for citizenship is tenacity through bureaucracy :)

@Kaaven, is the other half learning to call my cookies "biscuits"? :)

Dan Fedor - Founder, Blue Bottle Games

Kevinfu510's picture

i thought you were a canadian to start with! XD (no offence)

<a href="" title="View Apocalypse Scavenger on Indie DB" target="_blank"><img src="" alt="Apocalypse Scavenger" /></a>