SRL Archive - Help and Support

"Random();" algorithm?


EvilChicken!

2009-01-04 00:49:57

I would be really grateful if someone provided me the algorithm for the "Random();" function. (If possible?) I'm just interested in seeing how it is made. Tried googling, no results.. I may have overlooked something, but I doubt it.

Naum

2009-01-04 06:03:32

I dogpiled it :).
I found this, sorry if you went across it.

http://en.wikipedia.org/wiki/Random_number_generator

EvilChicken!

2009-01-04 06:16:42

From: NaumanAkhlaQ
I dogpiled it :).
I found this, sorry if you went across it.

http://en.wikipedia.org/wiki/Random_number_generator


.. wow.
Nope, I don't think I understand too much of that, I'd prefer to see some pascal code for it. But thanks anyway!

Naum

2009-01-04 06:25:31

Found some

http://www.merlyn.demon.co.uk/pas-rand.htm

boberman

2009-01-04 10:32:35

:), pretty much it is just a call to some pascal random number generating library and then a mod. In c++ it would look like int Random(x) { return rand() % x; }

Gu3st...

2009-01-04 10:55:06

From: boberman
:), pretty much it is just a call to some pascal random number generating library and then a mod. In c++ it would look like int Random(x) { return rand() % x; }

Well.. How is the algorithm of rand() then? -.-'

mastaraymond

2009-01-04 13:02:48

From: Zytex!
Well.. How is the algorithm of rand() then? -.-'

Quite complicated ^.^

Bobarkinator

2009-01-04 14:06:45

It's impossible to generate 100% random, so they make the algorithm complicated to get as close as possible.

boberman

2009-01-04 14:24:35

From: Bobarkinator
It's impossible to generate 100% random, so they make the algorithm complicated to get as close as possible.


not quite impossible. It is impossible to have a finite equation generate a random number, however, random number devices do exist. They work by measuring things like quantum decay ect. Pretty complex stuff.

Look up the Wikipedia article, it has the most common random number algorithms. Most of them are based on a seed, generally, the current time is used.

R0b0t1

2009-01-07 17:58:40

In linux, there is /dev/random which provides totally random output. In Windows, if you perhaps picked a random box (coords from the regular random function) and then picked the x, yth location (coords from regular random function, again…) you'd probably get completely random input (mathematically, anyway).

Or, you could count the micro-seconds between keypresses and use the smaller (ones and tens place, etc) numbers.

Wizzup?

2009-01-07 18:54:02

From: R0b0t1
In linux, there is /dev/random which provides totally random output. In Windows, if you perhaps picked a random box (coords from the regular random function) and then picked the x, yth location (coords from regular random function, again…) you'd probably get completely random input (mathematically, anyway).

Or, you could count the micro-seconds between keypresses and use the smaller (ones and tens place, etc) numbers.


Pardon me, but I don't see how adding Random's up makes stuff totally random. You can still get exactly the same pattern by repeating it with the same 'random' numbers.
Also, /dev/random as far as I know, is based on stuff in the memory, other info in /dev/, hardware noise, interrupts and the time? (All the stuff that is unpredictable…?)

boberman

2009-01-08 01:39:53

From: R0b0t1
In linux, there is /dev/random which provides totally random output. In Windows, if you perhaps picked a random box (coords from the regular random function) and then picked the x, yth location (coords from regular random function, again…) you'd probably get completely random input (mathematically, anyway).

Or, you could count the micro-seconds between keypresses and use the smaller (ones and tens place, etc) numbers.


Programming logic is static, the only source of truly random numbers is from quantum decay. As Wizzup said, two psuedo random number are not equal to a truly random number.

Generally we shoot for "Good enough" as far as randomness goes. We have some pretty good psuedo-random number generators (see Mersenne Twister) that work well for places that need really random numbers (statistical analysis, cryptography). However, since most here aren't concerned with much more then making a realistic bot, the psuedo random number generator provided by most languages is almost certainly enough (so long as a new seed is assigned each run of the application. It would be bad if you used the same seed as that would produce identical clicking… Not good)

Any good 2d random algorithm is good enough for botting. (see wikipedia article on psuedo random number generators)