How can I make my random number sequence persistent between games?
I am making something that is procedurally generated using a fixed random seed. This is fine but if the player exits the game... how do I make the random sequence continue when they next load the game?
There doesn't seem to be any way to save the current state of Core.random
Comments
https://deluxepixel.com
random seed = 12345678
advance using 13956884
advance using 14019841
advance using 14081215
advance using 14123875
advance using 14154412
advance using 14187182
advance using 14207933
advance using 14227556
advance using 14247235
Which seems to be terribly wrong in my mind because all I am attempting to do in advance() is get the current random seed. If that's syntactically correct then why am I getting different numbers when I haven't even called Core.random() at all?
It seems like it is counting up like something is adding to it constantly.
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
I would think that Core.randomSeed() should always return the correct seed, not something that seems, well, random.
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
save the seed = 12345678
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Internally this modifies the seed (I think).
I call Core.randomSeed() to get the seed when I want to save it.
The problem is that Core.randomSeed() does not return the actual seed, instead it seems to be returning something completely random, which is not what I require.
I hope that makes it a bit clearer
I want to save the state of the random number generator so it can be used on next program load.
I'll just not use it and find another solution. In future it might be good to have such a feature though
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
- I am making a game where each level is procedurally generated.
- I am using the new Core.random system so that the generated results are the same for all devices.. so if I have a random seed of 1234 then on Android, IOS, and Win32 I will generate the same level on all platforms.
- The game never ends so when the player leaves the game it saves the random state.
- When the game is run again it loads the saved random state and continues generating random levels from where it left off.
- Using this system the game is the same on all platforms and the levels generated are all the same, between game sessions.
So a player who played 50 sessions and made it to level 1000 on IOS sees exactly the same level as a player who played on Android for 5 sessions and reached level 1000.
Now if the random seed that is returned by Core.randomSeed() is a time stamp then all subsequent games will differ wildly because depending on when the game was exited on any particular device.. the randomSeed returned by Core.randomSeed() will be different.
Am I correct then at saying this is useless (not going to work) for me? or am I really not getting the point?
It has two functions:
1°) it returns you the current seed (so that you can resume an ongoing rrandom sequence)
2°) it allows you to set a new seed
both functions are executed at the same time during the call:
So you can still use the oldSeed, save it, and resume your game with Core.randomSeed(0,oldSeed).
You see ?
Likes: oleg, SinisterSoft
This saves and increments a seed, producing the same random number on any device (well, I tested it on Mac and Android, try it to see if it works for you!).
@totebo that's pretty cool, just adjusting the seed by one. That would work but it does not save the true state of the random number generator.
I know I'm being a bit "picky" but I want to save the state of the original seed as it unfolds. To this end I am looking for a pure lua based generator where I can get and set it's state as I please.
Sorry to all that I confused
Try this:
Likes: totebo
If you want things to be exactly the same between devices then use random integers instead.
https://deluxepixel.com
https://deluxepixel.com
Likes: totebo
https://deluxepixel.com
So now I have a basic random number generator that can persist between sessions I'm happy. This is it if anybody might find it useful..
Likes: SinisterSoft
Likes: antix
https://deluxepixel.com