Sorry if this is such a simple thing, but for some reason I can't get my head around it.
Imagine you have a world, that you have "seeded" with a value. You base all your randomisations off this value - perhaps you made mountains, monsters, or any other such thing.
Then the user saves her game, and then picks up where she left off a few days later.
We can store the seed we started with easily enough. But, it will reset to the beginning. What I would actually like is to "start off where we left off". Therefore, with persistence, do I need to be storing the iterations that we applied on said random number generator? When loading the saved game, do we go through the iterations to arrive at the place we should be?
An alternate would be to initialise a world using a random seed, and then throw it away when we save, so that any subsequent load, has a new random number generator.
Thoughts and ideas welcome :)
Edit
To reiterate from the comment I made below, my first thought was to wrap all access to the Random
class, and track the number of iterations. This could be saved alongside the seed. When loading, one would re-initialise the class, and then loop through the iterations (effectively throwing away the result) to arrive at the point you'd have been at originally.
Also, added c# tag.
java.util.Random
) that meets your requirements. Let's see what the experts say ;-) (Related, but did not read/understand it completely: stackoverflow.com/questions/7589388/… ) \$\endgroup\$