BlackToppStudios / Mezzanine

A game engine that supports high performance 3d graphics physics and sound
http://www.blacktoppstudios.com
18 stars 5 forks source link

Create a random number generator. #61

Closed MakoEnergy closed 7 years ago

MakoEnergy commented 11 years ago

C++11 has , but we can't use that because it's C++11. We need something else with comparable capabilities (within the context of gaming and game dev tools) that will compile on non-C++11 compilers.

The RNG should be able to generate a number in a specified range. Ideally have an API that can have either floats or ints passed into it. Additional utilities should be provided that will use that API and store a cache of results that will be compared against to "smooth" out the results. Both the number of results cached and how the generator reacts to repeats should be configurable (reroll once, reroll until number is n units different, etc.) but provide sane and common defaults.

Planned uses as of the time of this writing include placing an object in a random spot within an area and preventing or reducing the occurrence of double crits in an action game.

MakoEnergy commented 10 years ago

Here is a decent stack overflow post that discusses random number generators in the context of games: http://stackoverflow.com/questions/1046714/what-is-a-good-random-number-generator-for-a-game

One of the responses seems to mention a "shuffle bag" tends to be more appropriate for games, and it does seem appropriate at first glance.

Sqeaky commented 10 years ago

I will snag some of my dice rolling code from my d20 generator and prepare an object oriented version of it.

MakoEnergy commented 10 years ago

I did another bout of research for this, as I may want to knock this out after the UI refactor. Looking much more closely at the Shuffle Bag approach it does indeed seem useful for games and we may want to provide something like that in our API. However it doesn't find my more immediate need for random numbers, being generating a random position in a range on a Axis(X,Y,Z) for random spawn locations.

If your dice rolling code is for any reason not appropriate for these uses, I did also manage to find a medium sized library for generating random numbers here: http://randomlib.sourceforge.net/html/

Other then that, C++11 continues to taunt us.

MakoEnergy commented 7 years ago

A long time ago I added a Mersenne Twitster random generator to the engine. We may want to add more generators, however in addition to that implementation we have upgraded to C++11 since this issue was first opened, giving us access to the standard random generators. For now random numbers are a non-issue.