|
Post by aristarkos on Feb 1, 2012 2:18:22 GMT -5
If I stop my server, and restart it, and run this program, I get the same 1000 4-digit numbers every time.
cls
for x=1 to 1000
A=INT(RND(1)*10) B=INT(RND(1)*10) C=INT(RND(1)*10) D=INT(RND(1)*10)
print A; B; C; D
next x
end
What could possibly explain this?
The 1000 4-digit numbers start with... 6939 9642 5875 0593 8083 8889 6198 9036 0037 2181
The 1000 4-digit numbers end with... 2451 5267 2038 0825 1106 7753 6842 2810 9933 8325
|
|
|
Post by aristarkos on Feb 1, 2012 18:16:42 GMT -5
Can someone tell me if you get the same thing or not?
(don't forget to restart your server first)
|
|
|
Post by aristarkos on Feb 1, 2012 23:45:18 GMT -5
Is this what is meant by pseudo-random? Solutions?
|
|
|
Post by aristarkos on Feb 2, 2012 0:57:45 GMT -5
I came up with a pseudo solution. I'll understand if this thread gets moved to Coding Questions.
cls
t=time$("ms") t$=str$(t) lastthree$=right$(t$, 3) lastthree=val(lastthree$)
for dummyloop=1 to lastthree dummy=INT(RND(1)*10) next dummyloop
10 A=INT(RND(1)*10) B=INT(RND(1)*10) C=INT(RND(1)*10) D=INT(RND(1)*10)
ms=time$("ms") if ms/2=int(ms/2) then goto 10
print A; B; C; D
end
|
|
|
Post by StefanPendl on Feb 2, 2012 3:42:37 GMT -5
Currently there is no RANDOMIZE command available to seed the pseudo random number generator.
If one gets available you will be able to seed by current time for instance, which will only create the same random number sequence if you restart your server at the same second each day.
|
|
|
Post by aristarkos on Feb 2, 2012 9:31:04 GMT -5
Thanks.
I've pretty much accomplished that. My new version puts the starting position somewhere between 0 and 999 using time in milliseconds, and then forces a redo if the milliseconds number is even. In my main program, four 4-digit numbers are generated at each running. The redo makes the starting place for each 4-digit number jump ahead some unpredictable amount. That's enough variation so that even if the server was restarted every time, no one would ever notice a pattern.
|
|