Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / actualy make it random!

Author
Message
Mucky Muck Ninja
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location: im not entirely sure
Posted: 30th Jan 2004 01:51
Im using a random value for the direction of wind and it is the same number every time I start the program. Is there any way to set the random seed generator or something like that to make it actually random every time the game starts?

Am I an Idiot...or is everyone else just really smart?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Jan 2004 01:52
At the top of your program ...





For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
SoulMan
22
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 30th Jan 2004 02:11
Speaking on this,
In a sense there is no way to get the computer to produce a real random number. Part of this has to do with the data that you give it. Example of this. Given a range of 1 to 8 and telling the computer to print out 10 numbers from this range you will get the same number order each time. While Seeds help to produce different results from this, if you use the same seed value you will also get the same result. IanM's way is probably as close as you will get to getting a real random number since it is based on time and each time a second goes by it gives a different value. I haven't used the timer function just yet but if it is based on Milliseconds then you have ample numbers as seeds. However there is still a small chance of getting the same results even with this, but that chance is very tiny. I think at some point we will be able to get real random numbers but we haven't gotten there yet. We would have to base the seed number off a value that is truely random at times. A good example of this would be the stock market value since that value is driven by humans and not machines. The only thing is that the value stops changing when the market closes. I think I might go find a book on the subject.
Anyway, that's my .02 for the night.
SoulMan

This is as backwards as is This
zircher
22
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 30th Jan 2004 02:30
Well, you could multiply the timer by the date (ie. 20040129) to further scramble things.
--
TAZ

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th Jan 2004 04:09
There is no such thing as "random". No matter what, there's always a pattern, even if it can't be found. Even PI has a pattern.

(I'm just rambling about the movie now)

"eureka" - Archimedes

Login to post a reply

Server time is: 2025-06-02 13:53:06
Your offset time is: 2025-06-02 13:53:06