True Random Numbers For TI-99/4
Regena writes about randomness on the 99/4 in her column in the February issue. I would like to share some discoveries I have made on this subject with your readers.
First of all, there seems to be some confusion about how the RANDOMIZE statement works in TI BASIC and TI Extended BASIC. As Regena pointed out, if you do not use this statement in your program prior to using the RND function, you will receive the same sequence of numbers each time you run the program. All your friends around the country with 99/4's will get the same numbers as you do, too. When the computer encounters the RANDOMIZE statement, it puts you back at the beginning of a new list of pseudo-random numbers.
That term "pseudo-random" is important. The 99/4A User's Reference Guide makes a point to mention that the RND function "gives you the next pseudo-random number in the current sequence of pseudo-random numbers." If you use the RANDOMIZE statement once, then, you may or may not get the same sequence of numbers. However, using the RANDOMIZE statement over and over again in the program just puts you back at the beginning of another list. In reality, there seem to be certain numbers that the computer prefers to put at the top of its lists, so in games there may be some numbers that are never generated because you never make it far enough up into the current list to get that number. The point is, repeating the RANDOMIZE statement does NOT make your program more random.
I have found that the only way to make the computer generate a totally unpredictable set of numbers is to use the RANDOMIZE statement once at the start of the program, then when you need to wait for the user to press a key, do this:
100 CALL KEY(0, K, S) 110 Z = RND 120 IF S = 0 THEN 100
Since the time it takes a human to press a key will not be exactly the same each time the program is used, the computer will read down the list of pseudo-random numbers an unpredictable number of places.
Steve Davis