This question already has an answer here:
I have game based on random generated content. I am using System.Random with specific seed to be able to predict my random outputs. But now I have problem with saving of game, because I need somehow save progress of my System.Random instance to be able to continue with know random outputs after load. Right now Iam saving only seed of my random and creating of new instance of Random will generate same values from begining.
Lets imagin this situation: I will create Random with seed "x" and generate 4 numbers - 84, 68, 12, 98 next I save a game and load again from save and it creates new instance of Random with same seed "x" - this means, that next 4 generated numbers will be 84, 68, 12, 98 again, but i need to continue with sequence and not starting from begining again. Is there any way how to do it elegently, or I need to save some valu that will hold "count" of uses of my Random instance and call Random on my new instance Random instance "count" times?
Aucun commentaire:
Enregistrer un commentaire