May I use MersenneTwister as I want ?
#2
Basically, you are right.

1, Yes, you can, but as you've already noted, it's quite some heavy-lifting to do so. If you can work around it, go around it.
2, Yes, you can, theoretically, as long as you can guarantee a single thread accessing it at a time (locking etc).

For these reasons, there is an MTRand instance within cWorld that is to be used in the Tick thread exclusively and has some accessor functions in cWorld directly (GetTickRandomNumber() ). If you can guarantee that your function runs only in the tick thread, you can use it.

Usually, we don't even need such a big random function; if you just need a reasonably random number, you could use the cNoise IntNoiseNDInt() functions, feeding them some clock-based values, such as the number of ticks elapsed in the world, world seed, and probably some kind of a static counter.

Another question is, how does MTRand fail when used in multiple threads? Does the failure produce crashes, or does it simply just somewhat degrade the resulting random numbers? If the latter, I'd personally go with abusing that and simply using it from multiple threads.
Reply
Thanks given by:


Messages In This Thread
RE: May I use MersenneTwister as I want ? - by xoft - 07-04-2013, 01:58 AM



Users browsing this thread: 1 Guest(s)