mIRC Home    About    Download    Register    News    Help

Print Thread
#75494 16/03/04 06:45 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
One of the scripts I use extensively uses $rand. However, it's performance leads me to believe it isn't as random as I thought at first, there definately appears to be some form of pattern in the output. That reminds me of back when I played with C++, I once read that the randomize function in C/C++ actually uses the computer's clock in some way ti seed the function. I also remember there was a way to go around it so you get a real random number. Anyone have any hints on how to make $rand pick a real random number?


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#75495 16/03/04 07:17 PM
Joined: Dec 2002
Posts: 111
F
Vogon poet
Offline
Vogon poet
F
Joined: Dec 2002
Posts: 111
I've heard of this problem too..I think someone said once that mIRC uses $ticks to get the random number..but then in one of the new versions of mIRC recently I think $rand was improved upon..

But I'm not sure. Ironically, I don't know how to do what you're wanting, I just thought I'd throw in my 2 cents.


Experience The Void.. Are You Ready?
#75496 17/03/04 12:52 PM
Joined: Jan 2003
Posts: 1,063
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2003
Posts: 1,063
c++ uses ctime as a seed for the random... which is utter crappy for randoms :-]

if you do several randoms within one second you get the same random integer... :-[ (had to test this for school...)


If it ain't broken, don't fix it!
#75497 17/03/04 02:35 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Which is what I concluded. Good thing to know I'm not completely losing it. So then we return to the original question: How do I get a truly random number.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#75498 17/03/04 02:37 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
you can't?


New username: hixxy
#75499 18/03/04 06:59 AM
Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
or you could seed the rand algortihm with a random number?

I know that you can't self seed in mIRC - but maybe a random loop ( e.g. loop for $rand(1, 100) times) would stop on a random 'tick' which makes it less predictable.

Cheers,
DK


Darwin_Koala

Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
#75500 18/03/04 07:27 AM
Joined: Jan 2003
Posts: 428
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Jan 2003
Posts: 428
Ah yes, here we are... I was sure that this had come up on the boards before.

This post makes the point that random numbers are only pseudo-random.

PM


IRCnet & DALnet @#travelersinn
:-: IRC for fun and relaxation :-:

Link Copied to Clipboard