-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I encode a seed as JSON? #17
Comments
If you used |
Hi @rlefevre 😄 |
@ChrisPenner Maybe you could generate an Another way would be to keep the number of steps run to re-run them all at once, but this may be difficult if you use several complex Random generators. |
Generating an int from the current seed and using that would still mean the clients are out of sync. It may seem like a weird thing to want, but I'm actually experimenting with different methods of syncing distributed clients using CRDTs and it's important I can sync up their "randomness".
This sounds absurdly complex (and nonperformant) to keep track of across distributed clients 😬 You haven't mentioned why the hesitation to provide a |
Why? If the one generating it also uses it as a new initial seed, they would all be synchonized, wouldn't they?
Because I'm not convinced by the need yet, so I prefer to help finding a solution that could work now. If none works, this also helps illustrating why it would be useful. |
Apologies for jumping in, but I could definitely use the same functionality that is being requested. My use-case is a SPA that initially takes its random seed from the time, and then proceeds deterministically using a PRNG seeded with that. It'd be useful to have a As a workaround, it's pretty easy to just clone the repo, create these trivial functions ("backupSeed" and "restoreSeed"), and move on with life, so I don't particularly mind whether it's in the "official" repository or not. But it seemed useful to me to point out that there are other use-cases, and perhaps (more contentiously) that adding a couple of functions isn't such a terrible idea, and really won't break anything at all. |
I concur with the others, |
I've got a usecase for The seed would have been stepped through thousands of times, depending on how long the player has been playing, so it's not feasible to track the steps and re-run them on load. I think I'll have to hack around this by taking each new seed from Being able to serialize and load the seed would be great for my case. |
I have the same issue. . . I want to store a game seed and then be able to get
^^ this doesn't work with this Elm compiler since elm/random is an
So the workaround is actually to fork the elm compiler and flip the flag that disallows effect modules back to false. And then to copy it as above. May we just have the |
Hey! Just putting myself down as someone who's interested in this issue. Any more word from a maintainer on whether or not this function ought to exist? Thanks 👍 |
Hey there! Hope you're doing well! I'm building a browser game where many clients are synced up and I need to share seeds amongst clients;
I can get a
Random.Seed
into elm no problem by usingRandom.initialSeed
; but once I have a seed I can't serialize it back into JSON; Is there any way to encode a Seed? I simply need either aRandom.Seed -> Int
or aRandom.Seed -> Json.Encode.Value
Does this exist; or would it be possible to add? I'm a bit stuck on this one 😬
Thanks for your help!
The text was updated successfully, but these errors were encountered: