Skip to content
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

serializing state to resume generation from the same point #179

Open
BrianHicks opened this issue Jul 12, 2024 · 3 comments
Open

serializing state to resume generation from the same point #179

BrianHicks opened this issue Jul 12, 2024 · 3 comments

Comments

@BrianHicks
Copy link

Hi! I'm interested in using this library in a local-first application to generate data in a consistent way across different clients. Because of that, I need to be able to serialize the state somehow to reuse later. I've used other implementations of PCG where this is possible, but I don't see a clear way to do it here—if you don't mind my asking, how would you recommend approaching this?

@philihp
Copy link
Owner

philihp commented Jul 24, 2024

Ohh, I can see how that would be useful.

I've been meaning to do a bigger overhaul of this library for another major version. I'd be happy to include that. Would you be able to share how you're using it (or any similar library)?

@BrianHicks
Copy link
Author

Well, to level-set, this is just in a hobby project, and I don't want to appear to be making demands!

But essentially, I'm making something similar to TagTime. For that to work, the checkins ("pings") are randomly timed, but the overall spacing needs to follow a particular distribution.

To add another wrinkle onto this, I'm storing all the data in an automerge document, so I don't have the benefit of a central server to coordinate inserting pings.

Given the constraints, PCG seems like a great option for this: I can hypothetically store/restore the state information to get consistent results across different clients (and possibly different languages.) That's not the only way to do it, though: having a consistently-seedable implementation means I can also use the timestamps of the pings to get a repeatable source of randomness. 👍

@philihp
Copy link
Owner

philihp commented Oct 28, 2024

of course :) this library can totally be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants