Efficient Random Number Generator in C++
I have created an application that needs to create random numbers very quickly. I have seeded it using the time function but this seems to produce the same random number when used quickly. Anyone know of a better seed i can use or a better way of doing it.
Cheers.
Are you using rand()?
the problem could be that you are seeding it every time before you use it.
=======================
Game project(s):
www.fiend.cjb.net
the problem could be that you are seeding it every time before you use it.
wrong:while(1){srand((unsigned int) time(0));rand() //however you use it.}right:srand((unsigned int) time(0));while(1){rand() //However you use it.}
=======================
Game project(s):
www.fiend.cjb.net
=======================Game project(s):www.fiend.cjb.net
Seeding the random number generator with time then calling rand() does not produce real random numbers , but alas it is useful .......... *sigh*.
Hulk -> Hulk Mad hulk smash.
SpiderMan->Oh Shut up , I got gas but you dont hear me bragging about it .
Hulk -> Hulk Mad hulk smash.
SpiderMan->Oh Shut up , I got gas but you dont hear me bragging about it .
I was influenced by the Ghetto you ruined.
There are no such things as ''real random numbers'' anyway. Not when you''re dealing with computers anyway. At least seeding should give you more or less *different* numbers every time you run the program. Fango, if you want more control over your random number function, try investigating the Monte Carlo method - you can make it as fast or as ranging as you need.
r.
"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
r.
"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
There are no such things as ''real random numbers'' anyway. Not when you''re dealing with computers anyway. At least seeding should give you more or less *different* numbers every time you run the program. Fango, if you want more control over your random number function, try investigating the Monte Carlo method - you can make it as fast or as ranging as you need.
r.
"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
r.
"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement