How can I avoid the string of Random numbers repeating in QB64?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
rockyabq
Newbie
Posts: 2
Joined: Fri Jan 23, 2015 11:32 pm

How can I avoid the string of Random numbers repeating in QB64?

Post by rockyabq » Fri Jan 23, 2015 11:49 pm

Brand, spankin' newbie here...

I'm simulating randomly created striations (scratches) on a pair of bullets and comparing them. This requires huge invocations of RND. There are 300 possible sites on each pair that are chosen to be either striation or non-striation using RND. After half a million or so pairs of bullets, the patterns generated recur because the length of the string of pseudo-random numbers that QB can make has been exceeded and the numbers begin to repeat. It makes no difference whether I RANDOMIZE with a seed number or with RANDOMIZE TIMER. I tried a line to the effect of IF RND>.95 THEN RANDOMIZE TIMER. No help. Any ideas?

Thanks in advance,
Rocky

User avatar
burger2227
Veteran
Posts: 2220
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: How can I avoid the string of Random numbers repeating in QB64?

Post by burger2227 » Sat Jan 24, 2015 9:50 am

Random numbers repeat themselves at times eventually and with QB there is no way around it.

You could try to seed the numbers using TIMER which should give you a more random starting point but you will never be 100% happy as random repeats itself in real life.

QB64 can use RANDOMIZE USING seednumber also to repeat a new number series. You could try that, but they all repeat themselves eventually.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Post Reply