Trying to find a better way to generate random numbers in Dev Pascal

Reply

Join Date: Jun 2005
Posts: 12
Reputation: Shadowhawk is an unknown quantity at this point 
Solved Threads: 0
Shadowhawk's Avatar
Shadowhawk Shadowhawk is offline Offline
Newbie Poster

Trying to find a better way to generate random numbers in Dev Pascal

 
0
  #1
Jun 21st, 2005
Hello to everyone who sees this post!

I am not very experienced in programming, but I have some basic knowledge, and the first real programming language I happen to learn is Dev Pascal. I have compiled a program which generates random numbers, using the RANDOM(); function. It is actually a dice roller.

The thing is, that every time I run the program, I get the same sequence of numbers. For example, if I run the program and get 4, 2, 1, 6, the next time I run the program, I will get again 4, 2, 1, 6!

I have searched the Web and found out that this problem is due to the mathematical expression the RANDOM(); function uses, and this makes it "generate" the same numbers every time it runs again, as the "seed", the initial value of the number it uses, is the same. But those ARE NOT random numbers!

If there is anyone who can help me find a better way to generate REALLY random numbers, please, do so! I don't know if there is the possibility to get clock values in Dev Pascal, and if there is, how to use it... Any help will be appreciated. PLEASE HELP ME!!! PLEASE!!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 31
Reputation: Jackrabbit is an unknown quantity at this point 
Solved Threads: 0
Jackrabbit Jackrabbit is offline Offline
Light Poster

Re: Trying to find a better way to generate random numbers in Dev Pascal

 
0
  #2
Jun 21st, 2005
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 12
Reputation: Shadowhawk is an unknown quantity at this point 
Solved Threads: 0
Shadowhawk's Avatar
Shadowhawk Shadowhawk is offline Offline
Newbie Poster

Re: Trying to find a better way to generate random numbers in Dev Pascal

 
0
  #3
Jun 22nd, 2005
Thank you, Jackrabbit! It really worked!
The error was the missing Randomize; in the beginning. I had the same seed every time, thus getting the same sequence of numbers! Thanks again!
Actually, I found the answer myself, just a few minutes after I posted that... in another website... But the thought and only is worth it! thank you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC