[Coco] Is the RND command really generating a random number?

Melanie and John Mark Mobley johnmarkmelanie at gmail.com
Sat May 20 13:39:22 EDT 2017


How to randomize the random number generator...
Read the analog to digital converters, joysticks, or mouse.
Read the last value written to the digital to analog converter.
Read the system timer or system up time timer
Read the condition codes, registers (D, X, Y, U, S), and some data on the
stack from the last time an interrupt occurred.
Read the last byte to come in on the cassette port.
Read the last byte to come in on the serial port.
Read the last byte to come for the network interface controller.
Read some data for the last sector read from the floppy or hard drive.
Read the elapsed time between the last two key strokes.
Read some data for the text screen or video screen memory
Read the real time clock.
Read a temperature sensor.
Read a barometric pressure/atmospheric pressure sensor.
Go out to the internet and read a weather report.
Go out to the internet and read the stock market.
Go out to the internet and read the news.
Then add this all up and use this value to seed the random number generator.

N=rnd(3) => N= 1, 2 or 3
N=rnd(2) => N= 1 or 2
N=rnd(1) => N=1
N=rnd(0) => N=0 to 1 as in 0.0001 to 9.9999
N=rnd(-1) => N=0.522222848
N=rnd(-2) => N=0.522222849
T=timer
If T >= 32768 then T=T-32768
RAM=peek(T)
DAC=peek(&HFF20)
N=rnd(-(timer+RAM*4096+DAC)) => This will randomize the random number
generator

John Mark Mobley




More information about the Coco mailing list