Bugs squishie-squashed
In installing OutNumber to my iPod touch (finally) I found two, game changing, bugs. Wait, of course they were game changing, OutNumber is a game…
The first I ran into was one that displayed the wrong result at the end of the game. You see, when you finish a game in OutNumber, it gives you the option to also show the best game you could have played. The problem was that a variable wasn’t being reset between games resulting in the second game showing the perfect game if the player left their score showing and not the other score. It was a minor problem but it shouldn’t have been there nonetheless.
The second bug was more dangerous. In order to simulate the rolling of a dice I’ve used the standard rand() and srand() functions. If it isn’t entirely obvious, “rand” stands for “random”. In other words I’m using a random number generator. Computer random generators are in no way perfect. In fact, it’s highly probable they will never be because in order for a computer to generate a number it needs to have a limit of total numbers and an appropriate way to find the number. Computers read and communicate using mathematics. The thing about maths is that there’s always a method that can be figured out, either by another computer or even by a person. That was the problem.
Before you can use the rand() function, you need to “seed” it by giving it a starting point to generate a random number. The typical (and easiest) seed to use is time itself. Using the time known by the computer, a new number can be generated every second. Something I just learned today is that seeding the random number generator every second results in a pattern. In OutNumber’s case, if you were able to roll the dice, place the result, and then roll the dice again within a second, the next roll would be the next number along. Using this method you could achieve a maximum score of 70329 (1+32+654+4321+65321) if you were fast enough.
What had happened was that I had not isolated the seeding process and so it would continually be reseeded every time the dice was rolled. What’s funny is that I had subconsciously figured this out and could win almost every game perfectly. Now it’s much harder.
Thank you for reading.
