The best pseudo random number generator free for use in internet is

ISAAC is so good what you can use to statistical issues. You can find

this in

http://burtleburtle.net/bob/rand/isaacafa.html

Best regards,

Frank Alcantara.

Thyamad Consultoria.

@Frank_Alcantara

http://www.thyamad.com

-----Mensagem original-----De: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] Em nome de Atrix

Wolfe

Enviada em: quinta-feira, 13 de mar?o de 2003 14:03

Para: sdl at libsdl.org

Assunto: Re: [SDL] A better rand()?

Sam, since truly random numbers are impossible to generate, what your

looking for is a sequence of numbers which apear random.

I suggest you look up “chaotic functions” on google. Chaotic functions

are

functions which are sensitive to intial conditions. That means if you

put 3

into the function it could give you 43, but if you put 4, it could give

you

1,536,938,657 and if you put 5, it could give you 200.

Hows this help you get random numbers you ask? Well at the begining of

your

program you:

srand((unsigned)time(NULL)); //seeds random number generator with

current

miliseconds

int Start=rand(); //Start=0-65535

what you do is plug Start into your chaotic function to get the first

random

number (lets say its 5). Then what you do is save this 5 so next time

you

want a random number, you plug the 5 into the chaotic equation to get

the

next random number, and keep going in this cycle.

Heres some code of how such a function would work:

#include <time.h>

#include <rand.h> //i think this is it…might be stdlib or math…i

forget

int ChaosRand(void)

{

static int LastNum=0;

if(LastNum==0)

{

srand((unsigned)time(NULL))

LastNum=rand();

}

//use LastNum as the input number into your chaotic function

//calc. the next number using the chaotic function

LastNum=somechaoticfunc(LastNum);

return lastNum;

}

thats the general idea. Now all you have to do is find a chaotic

function

which makes you reasonably happy in that it runs fast enough and gives

you

substantialy random numbers. You use this function the same way youd

use

rand() so if you wanted a random number between 0 and 9 it would be:

int i = ChaosRand()%10;

of course if you want something just quick and done, you could

pre-generate

5000 random numbers when your program fires up keeping an index of where

you

are in the array and when you run out, regenerate 5000 random numbers

and

set the index to 0. That would also make things nice and fast.

Hope this helps!

-Atrix

PS if you dig this and want to learn more about chaos, fractals and lots

of

other cool stuff, i HIGHLY recomend a book called “the computational

beauty

of nature”, i got mine off amazon.

----- Original Message -----

From: pamashoid@poczta.onet.pl ()

To:

Sent: Thursday, March 13, 2003 3:45 AM

Subject: [SDL] A better rand()?

U?ytkownik Sami N??t?nen <sami.naatanen at kolumbus.fi> napisa?:

On Thursday 13 March 2003 03:54, Samuel wrote:

Hey! great, thanks for the code snipit.

you are right about the system rand

even after i fixed my “stoner moment” in the code it still was more

sluggis than I cared for. and rand is still eating up my cpu

cycles,

i’ll give this a try.

Thanks again.

Samuel

On Wednesday 12 March 2003 5:45 pm, you wrote:

Oops. I sent this to the list from the wrong address, and it’s

sitting waiting for approval; I don’t want to resend it since

it’s

bound to end up getting posted twice, but it’s likely to take a

few

days so I’ll just forward the post to you.

Might wanna try reading from /dev/urandom as well. It will give

better

randomness instead of the standard C thingy.

Or if your mobo have random number generator like mine use it.

if your problem is mainly speed you can try to set random numbers

array

( or file with random nubers or any other storage ) at game start

( if this array is large enough ) nobody will notice the difference

PAMASH

SDL mailing list

SDL at libsdl.org

http://www.libsdl.org/mailman/listinfo/sdl

SDL mailing list

SDL at libsdl.org

http://www.libsdl.org/mailman/listinfo/sdl

SDL mailing list

SDL at libsdl.org

http://www.libsdl.org/mailman/listinfo/sdl