-
Notifications
You must be signed in to change notification settings - Fork 432
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
Add XorShiftRng::extract_seed #119
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure seed is the correct term here. As far as I know, the seed is the inital state, not the current one. Maybe extract_state
would be a better name.
Generally, I think a way to serialize the state of all RNGs is important. Perhaps we should explore ways to do this in a consistent way across all algorithms. Serde could maybe be useful.
However, the issue with serialization is that it breaks encapsulation. As soon as we merge something like this PR, we can no longer change struct fields without breaking user's code.
Serde would be way overkill and create a semver hell. |
I found this PR while reading this thread: https://www.reddit.com/r/roguelikedev/comments/6mk4k4/serializing_the_prng/ There the OP wants to serialize the PRNG state in a game. I agree that the name should be changed to |
Serialization should be provided by #189, which I think is the main motivation here. |
Do we really need a PR that adds 874 lines of code just to give access to four u32s? :-/ |
It's not to give us four Besides, once serde support for wrapping types and generalisation over constants allows proper handling of large arrays, it should be possible to reduce all of this to |
We have Serde support now, and it doesn't require 874 lines of code. |
Useful for serializing the PRNG and reload it later.