Understand the data, and understand how it is used.

Over the past few weeks, I’ve been struggling to get past a point of excessive complexity in the simulation code for my city builder prototype.  I went through a few different refactoring attempts trying and generally failing to manage the complexity.  But the most recent attempt finally appears to have succeeded, and I think it has also has gotten me one step closer to properly grokking data oriented design. (more…)

In beginning the simulation code of my city builder over the past few weeks, I’ve run into some difficulties with integers that quite surprised me.  For a variety of reasons, I want to ensure that the simulation code is absolutely completely deterministic, regardless of platform, compiler, machine, or any other variable.  While I’d need to do further research to properly justify this statement in all its details, my impression is that this is much easier to guarantee if one sticks to integer computations, avoiding floating point representations of numbers.

Of course, if one uses just integers in all computations (or even the somewhat fancier fixed point variants), then loss of precision becomes more important to deal with, whereas with floating point numbers, one can often get by ignoring such details.  Division in particular is the prime culprit. (more…)