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 / RANDOMIZE question

Author
Message
Wizard007
2
Years of Service
User Offline
Joined: 21st Oct 2015
Location: Lisbon
Posted: 8th Jun 2018 00:49
Will the use of the RND function after using RANDOMIZE (with a specific seed) produce always the same values even on different computers (with different hardware, etc..)?

I want to use it to generate worlds but want them to look always the same when using the same seed on RANDOMIZE and not run the risk of get a different world using the same parameters.
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 12th Jun 2018 00:20

Yes, this is my understanding. It's very reliable when used in the proper places in your code.
I love procedurally/randomly generated worlds! I think once AI takes over humanity, we will all be living in them,

We can easily test this theory. After all, experimentation is at least half the fun of programming!




Send your parents to noisy sprite demo hell... enter the D-Zone
Mage
11
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 12th Jun 2018 05:52
Wizard007
2
Years of Service
User Offline
Joined: 21st Oct 2015
Location: Lisbon
Posted: 12th Jun 2018 18:06
I got the same values
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 13th Jun 2018 21:20
Ditto for me.
Send your parents to noisy sprite demo hell... enter the D-Zone
gamerboots
9
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 16th Jun 2018 11:38 Edited at: 16th Jun 2018 12:04
try this:




In the long run this will save you a multitude of hairs.

- edit -
You only need to call randomize once. Using the timer() function as a parameter will give
you a different seed each time the program is loaded so :



will yield different results each time the program is loaded.

however, if you want the same numbers generated then yes use the same seed number.
Starshyne Emir
1
Years of Service
User Offline
Joined: 27th Nov 2016
Location: The Darkness Beyond Time
Posted: 18th Jun 2018 14:57
How nice is to see that there are people still using RANDOMIZE with pre-defined seed values to produce static lists of results to emulate disk stored data!

What I know so far is:

After the RANDOMIZE function is called, DBPro will generate a new random number for every RND call until RANDOMIZE is called again.

Example:


Every time you press the key, the same sequence of 0s and 1s will be generated - no matter which computer is running it, because RANDOMIZE and RND trust in simple divisions and modules to produce the results - and even if computer change, math remains the same.

The sequence generated in above code, however, may change if you add another RND onto it or change the range of any existing RND you already have.

Every new RANDOMIZE - even with the same seed number, will reset the sequence, allowing you to retrive the results how many times you need.

For example:


In this example, wer call RANDOMIZE with our seed before every RND call, and what we get is the same result for all RNDs.

Ah, don't forget that if you change your code in such way the amount and order of RND calls change, the result you'll get will change, because DBPro treats RND results accordingly on the order of their calls.
[size=+2]Forever and one[/size]
Derek Darkly
6
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 19th Jun 2018 01:38

I have read (somewhere) that different graphics cards may produce different results; I can't personally confirm this!
If this is true, it may necessitate some sort of predetermined seed list.

Come on, DBP Dragonlords! Awaken! Give us knowledge! LoL
Send your parents to noisy sprite demo hell... enter the D-Zone

Login to post a reply

Server time is: 2018-06-24 08:01:37
Your offset time is: 2018-06-24 08:01:37