What do you get when you rework, redesign, extend and simplify your conditional expression evaluators? You get bugs, that’s what you get.
Thankfully, nothing was terribly difficult to figure out, once I’d actually discovered that the bug was there at all. The problem was that I didn’t notice for about a day.
There’s a variety of things that can be tested for with conditional expressions within the Argus engine.
These include whether a given actor has been cast into a specific role for a scene (allowing for partial scene specialisations in performances), whether flags have been set on particular cast members or not, whether certain events have taken place, what actors know, and what an actor’s opinion might be about another actor or about a place or topic.
Likely there’s more to come.
In truth, I was a bit spoiled initially, when the object-oriented structure of scenes and performances enabled be to implement conditionals quite simply, and even better, nested-conditionals just came out in the wash, and worked flawlessly from the get-go.
That meant I didn’t actually need the expression evaluator to do a lot of heavy-lifting. If I needed to test for more than one thing, I could nest my tests. It wasn’t a big deal, because I’ve hardly had to do that.
But I can see the benefits of being able to lump multiple tests together into compound expressions and we’re getting very close to doing that more regularly now. Where possible, I find, it is nice to have your code adapted to what you are going to need before you actually need it. That way, you can just carry on.
So, I’ve had some refits and reforms sitting on my planning board from the moment I had a clear mental picture of what my future needs were going to be. I then pull one out occasionally when I need a break from writing the narrative side of things, and work on code instead.
When that last happened, I completely rewrote the text-rendering system. This time, it was the expression-evaluator. Neither rewrite was completely without glitches.
The most egregious of them was simply this: I converted the expression keywords to lower-case, and when I changed the actual table of keywords that they’re tested against, I missed two of them.
Testing for flags and testing for knowledge just plain failed, and I hadn’t put in a run-time error handler to catch the missed case in the new code.
Oops.
A useful lesson: If a complex code rewrite works the first time, you have a bug (and possibly more than one), but you just haven’t spent enough time staring at the code to find it yet. Ironically, code that’s got an initial, reproducible bug probably winds up more solid in the long-term than code that seems to work right – because you spent more time with your eyeballs pointed at it.
SNAFU (the story) is up to 140,000 words, and the work on that is going smoothly on days where I can put the time on it.