-
Notifications
You must be signed in to change notification settings - Fork 4
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
Wyrand seed size lower than recommendation? #18
Comments
For For the second part, seeding via a resource with a |
I didn't realize the plugin default impl was random - default calls new, which sets the Seed to |
Looking at it again the one thing I want to do is print the current seed (think an egui widget where you can set the seed or generate one) - is it possible to get the current seed from GlobalEntropy today? |
No, because the internal state of a PRNG is considered sensitive, so none of the PRNG algorithms |
Exploring some of this, it seems because of the generics involved, #[derive(Debug, Default, Resource)]
pub struct RngSeed<R: Sized + Default + AsMut<[u8]> + Clone + Send + Sync> {
seed: R,
} This then allows me to invoke impl<R: SeedableEntropySource + 'static> FromWorld for GlobalEntropy<R> where R::Seed: Send + Sync + Clone {
fn from_world(world: &mut World) -> Self {
if let Some(seed) = world.get_resource::<RngSeed<R::Seed>>() {
Self::new(R::from_seed(seed.get_seed()))
} else {
Self::from_entropy()
}
}
} Now, I want to figure out whether to always initialise a |
I think bevy_rand should always initialize it by default (moving the
I think this is a generally useful feature - if I'm going to all this effort to have things be deterministic, I want the ability to try out runs (in my case world generation runs) with specific seeds for debugging purposes. |
I need to support cases where folks might be doing the resource initialisation manually, so to not fail and fallback correctly to sourcing entropy from OS sources. Like, maybe they want the You can check out what I did with #19, where
I think the same should apply to |
The
Seed
trait docs suggest seeding with an array of[u8; 12]
to avoid picking RNGs with partially overlapping periods - Wyrand uses[u8; 8]
: https://docs.rs/rand_core/latest/rand_core/trait.SeedableRng.htmlWe also need to seed the prng on plugin init via
with_seed
- was wondering if something like this has its place in the library.The text was updated successfully, but these errors were encountered: