![]() |
Random...
I remember a while ago Kai posted here about the random not being random. (http://forums.graalonline.com/forums...ad.php?t=44692)
What happens is that when random is used in a timeout, it forms a pattern, though it doesn't do this when used in for. So I made my own little graphing thing quickly and messed around with it. It seems the pattern is ALWAYS the same(if the same values are entered), no matter how many times it's called. Though the beginning is always different, after a few it begins to fall back on what seems to be the same pattern. See in the animation, these are the separate graphs I made. http://img411.imageshack.us/img411/1...hrandomov4.gif I guess this isn't really a tech support thing, but I noticed Stefan seems to be frequenting the tech support section a lot lately, so I really just want to know why this does this. And would it effect things like baddies using random functions to determine successful attacks or such likely scenarios? I could understand patterns emerging, but why the same pattern, each time, and why isn't the beginning part of the pattern? |
To fix that there would have to be a way of reseeding the random generator, like the srand() function in C++. I found a fairly good explanation of why it's needed here: http://www.bergen.org/AAST/Projects/...son4/rand.html
|
:o
|
that's why it's so easy to win chance events :P
|
There are special random generators, might work better:
PHP Code:
|
You have to think, how can you get a random variable? Your computer drops a ball, andwhereever it lands? Nah. They have to have some sort of formula.
|
Stefan strikes again.
There is no such thing as Random on the computer, its known as Pseudo-Random, in the Java source that is. Using the time (timevar2) as a seed is always best, because its never the same :D |
Assuming you seeded every one second. :o
|
Well for the seed i multiplied with one million, so its taking the micro seconds which should be random enough.
It is possible to switch the script-random() function to a better random generator, might be good to test those two other generators and see if they are better. |
Quote:
|
| All times are GMT +2. The time now is 07:54 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.