dilwyn wrote:That's what I thought - it seems there's no more to it than there is no error message to cope with a programming mistake like this.
The original question I was asked is possibly more interesting:
Code: Select all
"I am trying to write a program to illustrate the fact that the so-called random number generator is actually nothing more than a mathematical equation. I don't know the equation, but I think it can be demonstrated by writing a program which will produce repeating patterns by varying window sizes to allow the random number generator to drive a pattern generator. Do you know the equation? Or do you know of any programs which will do this?"
I don't know where to start trying to answer this one. At least I've never been asked this before, unlike some of the never ending same old common questions!
Dilwyn,
Like always, the code is the answer:
RND(t+1) = (RND(t) & $ffff0000) * $c12d0000 + (RND(t) & $0000ffff) * $712d + 1
Code: Select all
rnd
move.l sb_rand(a6),d0
move.w d0,d4
swap d0
mulu #$c12d,d0 ; multiply up
mulu #$712d,d4
swap d0
clr.w d0
add.l d0,d4
addq.l #1,d4
move.l d4,sb_rand(a6) ; and save it
(from rnd_asm in SMSQ/E sources)
Whatever that knowledge would be good for.....
BTW the rest of the question with windows and patterns I really didn't manage to understand.
I remember writing an article for the Toady once that was on RND and RANDOMIZE with some application of the characteristics of the RNG providing repeatable patterns. Maybe that person wants to look it up.
Tobias