RND is used in BASIC to tell the computer to use a random number, and in most cases, the result appears random. You can roll a dice, and the result will appear different each time - Randomly.
BUT, it's far from Random, and I have proof!
I typed up a simple program on the Sam Coupe to see what would happen.
10 MODE 4
20 PLOT PEN RND*15,RND*255,RND*172
30 GOTO 20
And you get this at the start...

... with the black space filling out with random colours as the program runs. It's a simple program, leave it running for a few minutes and you'll see something strange happening. I won't tell you what it is, it'll spoil the surprise, but let's say, you'll see order in the chaos.
Surprisingly, not only do you see a de-randomisation of colour, but also distribution of PLOT co-ordinates. If this was truly random, it wouldn't be so ordered, but the large amount of data produced shows up the cycle.
Let's break the program down...
MODE 4 tells the computer to switch to 16 colour mode where every pixel has an individual colour.
Next, our PLOT command has a few values:
- PEN gives the colour of the dot, where the random number is between zero, and anything up to 15.
- Next value is the X co-ordinate, and we've set a random value between 0 and 255
- Final value is the Y Co-ordinate, where we've done the same between 0 and 172
Finally, we create an everlasting loop that goes back to the PLOT command to keep plotting more coloured dots.
You can play around with the program and change the MODE value to 1,2 or 3 for slightly different effects. Because of the attribute clash, the results on modes 1 and 2, the output does appear slightly more random, and it's overwriting the colour of the dots in that 8x8 (MODE 1) or 1x8 (MODE 2) area each time a new dot is plotted.
For MODE 3, change the X width from 255 to 512, while there's a reduced palette of only 4 colours in MODE 3, the results are more similar to MODE 4. You can also reduce the colour range changing 15 to something else like 6.
So, what's happening, and what's broken?
Well, our 8-bit computers generate a seemingly random value by working through a sequence of 65536 different numbers. If you enter Print RND, you'll get a number between 0 and 1. To get our random number within a range, we multiply the range limit number by the generated RND number, so PRINT RND*37 will give us a random number between 0 and 37.
This article will be updated when we get hold of our ZX Spectrum NEXT to try it on.