dimanche 24 juin 2018

LibGDX internal calls to MathUtils.random() interfere with the sequence of random numbers generated

While using a random number generator (RNG) with a given seed several times (ie. each time calling setSeed() with the same seed to start over), I have encountered some deviation in the sequence of numbers generated on each pass. After banging my head against the wall a few times I found the reason to be this:

box2d's World.createBody() calls LongMap.put(), which calls LongMap.push(), which calls MathUtils.random() inside a while loop.

To my knowledge particle effects call MathUtils.random() too.

So how can I trust a sequence of numbers to always repeat itself if LibGDX internally uses the same static RNG instance and therefor could mess up the sequence?

How am I supposed to know exactly where and when MathUtils.random() is called outside my code?




Aucun commentaire:

Enregistrer un commentaire