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 Discussion / this is uh...disturbing

Author
Message
QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 2nd Mar 2003 04:37
I've got a great deal of solid code done on my multiplayer fps (it works online, I even wrote a chat function), but something bothers me. I have a matrix in my game to test ground phsyics. And I randomize it, which works fine. I randomize it at the start of the program
but...
every time I run the program, the matrix is randomized exactly the same.

now, considering that it is randomized, i was assuming when I compiled it and sent it to friends, whenever we "took a walk on the grass" we should clearly not have the same heights. The only thing my online code sends is the position of the character. The matrix is never sent. So I was assuming that occasionaly, where I saw a hill he would see an indent. But, to my amazement, the other characters clearly matched the ground height (which varied up to 100 units in height, so it's obvious I wasnt seeing the wrong thing.)

I'm not really complaining, it makes my job a lot easier right now, because both characters will see the same thing without me having to write a matrix creation function.

But can anyone explain this odd randomized matrix not being so random?
Darken the skies, we are god
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 2nd Mar 2003 04:43
This may sound silly, but would placing Randomize Timer() at the top of your code help? If this effects the Rnd() seed, it may have an effect on the Randomize Matrix also.

Just a passing thought

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 2nd Mar 2003 05:24
actually, that's probably it. DB probably uses the same randomize function every time it runs a program, then changes it for each following one. Hmmm...

Darken the skies, we are god
Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 2nd Mar 2003 05:28
Hmm, I thought DB would've used a time seed so it would only be the same if you opened it at the exact same split second.

"Computers are useless they can only give you answers."
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Mar 2003 12:48
It is important to be able to reproduce random number sequences for testing and debugging purposes.

In any case, most languages that provide random numbers do this in exactly the same way.
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 2nd Mar 2003 22:51
Does randomising with the same seed at the beginning of the program make the rnd sequence exactly the same every time on every computer?

Once I was but the learner,
now, I am the Master.
QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 2nd Mar 2003 22:54
i havent put in rndtimer yet, i'm afraid that if I do i'll loose my consistant matrix and actually have to make a ground...heh

Darken the skies, we are god
EddieRay
22
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 3rd Mar 2003 16:27
DarkBasic probably uses the system supplied random() or lrandXX() or such that come with their C compiler or are provided by the platform's C runtime library. These routines are really NOT "random" in the true sense, they are just implementations of pseudo-random number generation algorithms. The beauty of this is that they are general portable, so if you run the same program with the same random seed on two different computers that have the same random function, the results will be the same.

As far as using the system timer to seed the random number generator, you don't really need to do that unless you want different results every time. If you just want ONE good result, then try different seed values typed in by hand for the RANDOMIZE command. Then when you get one you like, hard-code it in.

Hope this helps...

Ed

Login to post a reply

Server time is: 2025-08-08 20:40:04
Your offset time is: 2025-08-08 20:40:04