Closed ASneakyFox closed 8 years ago
Well, there's nothing stopping you from setting the MathUtils.random
's seed.
You can even replace the Random
instance since the static field random
of MathUtils
is not final.
The problem with doing that to MathUtils is that many things use MathUtils.random in libgdx all over the place. It would mess up the games underlying model because some particle effect or something is in the game.
This should not happen unless you use the Random instance from multiple threads.
No this can happen easily and all the time.
For instance, if I have the game running with a specific seed and see how it runs, then I decide it would look cool if the main character has a particle trail when he moves. Now this new visual effect will change the outcome of all the AI because its using the same random number generator.
Anything at all you change in the game of its view/rendering would possibly be changing the game's model.
Oh now I see what you mean. But I think that even a dedicated random generator instance would not let you accurately reproduce game sequences since FPS is not deterministic. Actually, you use the random generator more frequently when FPS is high and less when is low.
ah because it uses random inside of update calls. I guess I wasn't thinking it all the way through. I guess this was a pointless suggestion then. It would be cool if it were possible though.
I have a game I'm working on with procedural generation. To make testing easier I like to use the same random seed on every run.
Instead of using MathUtils.random for doing random stuff in things like the Wander steering behavior, it would be great if it used something like GdxAi.random(), and then allow me to do something like GdxAi.setRandomInstance(myRandom); so that the ai will play out the same way every time with all the other aspects of my game.
edit: also to add, this would be useful for games with save/load functionality. Without being able to set the random instance, players could reload their game over and over to get different outcomes and "cheat" the game.