Saturday, June 30, 2007

Computers Get it Wrong

The computer illiterate 95% of the population (no, just being able to use one DOESN'T make you computer literate) will tell you that computers never make mistakes, that they are always correct because they use logic and maths. They think this makes them cleverer than the previous generation of people, who blamed "computer error" for everything bad that ever happened.

Any programmer, of course, will tell you that computers DO make mistakes, BECAUSE they use maths and logic. Remember how the world was going to end in 1999 because of Y2K? Remember how Pentiums added 2+2 and got 3.999999? Logic is great until you encounter a statement like "I am lying to you when I say this statement is a lie". Maths is a great way of describing the universe, but it has SOME limits, like the fact that the number zero doesn't really exist, and therefore if you try to divide by it you're in trouble. When applied to computers, there are always limits on maths imposed by the hardware, maximum values on floating bit variables and integers, etc.

A fair while ago, I dropped a tongue-in-cheek email to the creator of Lux, Dustin Sacks, showing that if you sat there putting more and more armies into a country instead of finishing off your opponent, eventually the numbers wrapped around and your chock-a-block country went back to zero population. Even though no-one in a normal game would ever come REMOTELY close to the number of armies I was talking about, Dustin fixed the problem in a later release - or so I thought.

But not quite. See that room in the middle of the screen snapshot with 341 million soldiers in it? The turn before, it has just under 2300 million. Presumably, having reached the magic number of 256 (binary 8 bits limit), my population reverted back to zero plus the income from this turn, which I must admit, was fairly high by this stage of the game. It just goes to show that the best laid plans of mice, men and programmers will always provide a few "hidden features" (programmer jargon for "bugs") for the adventurous or just plain stupid to discover. Just like real life.

No comments: