Introducing the Colour Maximite 2


Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 6382
Posted: 11:46am 08 May 2020      

  Quote   have no idea how or how to use it to generate a series of pseudo random numbers.


Just use it like RND() returns a number between 0 and 1. The sequence is determinate. If you need a different sequence then change the initialisation of X in the function - same as using randomize.

The code is exactly what the C call to rand used in the Micromite firmware is doing. Found it on google and easy to program in Basic

It should run on any Micromite - try it.

My code for the distribution

  Quote  
cls
dim a%(799)
for i%=1 to 800*300
j%=pseudo()*800-0.5 'exactly equivalent to using RND()
a%(j%)=a%(j%)+1
next i%
for i%=0 to 799
line i%,599-a%(i%),i%,599
next i%
do
loop
function pseudo() as float
 static integer x=7
 static integer a=1103515245
 static integer c=12345
 static integer m=2^31
 x=(a * x + c) mod m
 pseudo = x/m
end function