-
Notifications
You must be signed in to change notification settings - Fork 120
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
Consider replacing seeds with rngs #197
Comments
The purpose of having seeds is to provide reproducible results by using the same seed while giving users the ability to specify the seed as part of their generation process. Having a hard-coded seed would defeat the purpose of this library. |
Sorry, I must have been unclear. The library already contains many hard-coded seeds. This proposal contains two parts: improving the hard-coded seeds, and adjusting, not removing, the interface by which the user controls dynamic seeding. As outlined in the patch above, instead of supplying a |
Some discussion with Ralith indicated that I may have been misinterpreting the proposal, so I'm re-opening it for further discussion and expanding the details. |
Seeds in noise-rs are used to initialize internal RNGs, which are in turn used to construct noise function internal states (currently just permutation tables, maybe other things in the future?). The heart of this proposal is to instead allow the user to pass in a reference to a user-constructed RNG and use that directly, via the standard let mut rng = XorShiftRng::from_seed(seed);
let noise = rng.gen::<SuperSimplex>();
noise.get(...); This has a number of benefits:
The proposed interface is not mutually exclusive with the existing |
What about a combined approach? I was thinking of providing some default method such as I still support @Ralith with this one though, I think adding RNGs would be a good idea and I would personally like it if it were implemented. |
32-bit seeds aren't great, and pervasive use of mostly-0 seeds may be causing odd results already. I propose that
impl Seedable for T
be replaced withimpl Distribution<T> for Standard
per rand 0.5 convention, withDefault
impls andnew
using anXorShiftRng
with a hardcoded seed for reproducibility and convenience.This would save users and implementers the effort of having to come up with a good seed (particularly when unpredictable results are desired) and improves the quality of randomness used at no cost. I'm interested in implementing this if people are on board with the idea. The changes involved might look like this:
The text was updated successfully, but these errors were encountered: