Taking a chance
Budding Uri Getters start here on the Amstrad machines -written by Jon Tarrant
Prediction is a game of pure chance, or is it? Perhaps it may indicate how successful you are at predicting, rather than just guessing, a number sequence. It might even indicate a latent psychic ability you never knew you had!
The game is loosely based on the Rhine card principle used to test psychic ability. In the Rhine test the object is to 'guess'the picture on one of five different cards being examined by a second participant; in this game the computer is that second participant. You are invited to predict what will be the next random number, in the range one to five, that the computer will generate. In order to avoid the inevitable fixed sequence of numbers that are generated simply by calling Rsid(l), the sequence is re-seeded with the clock value before each number generation. (To demonstrate the constancy of the Amstrad's random number sequence under normal conditions, reset the computer, then enter Print Rnd(l) a few times and note the numbers obtained, reset the computer again and repeat the operation comparing the numbers generated with those obtained the first time.) Line 630 is used to ensure a disrupted string of random numbers in the range one to five.
A final touch to avoid cheating is to disable the break key. This is done in Line 160 by removing the Rem keyword, but it is as well to do this only after having fully debugged the program.
One interesting pan of the screen handling routine is the use of transparent printing and changing Ink colours to make the printing visible or hidden as appropriate. Within each run of ten guesses, defined by the For. . . Next loop between Lines 530 and 690, the computer generated random number is printed over a coloured square using the same ink colour as that of the square. The control codes in Lines 650 and 670 enable and disable the transparent printing mode, while the Ink changes in Line 730 makes visible the computer generated sequence that has already been printed.
At the end of the game, the total number of correct predictions made is displayed together with the figure expected by pure chance.