🎲 perchance

A lightweight, quick, and easy-to-use library for generating and using randomness, designed for the most common use cases you find in games and geometry.

Note that perchance is not cryptographically secure and should not be used in contexts where security is a concern.

Usage

perchance is a simple random number generation library, tuned for ease of use: create an instance of PerchanceContext and go.

```rust let mut rng = perchance::PerchanceContext::new(seed);

let between0and1 = rng.uniformf32(); let diceroll = rng.uniformrangei32(1..=6); let randomdirection = rng.uniformspheresurfacevec3(); let thingshouldhappen = rng.getbool();

enum Event { Thing1, Thing2, Thing3, } let whichshouldhappen = rng.choose(&[Event::Thing1, Event::Thing2, Event::Thing3]); ```

You can also use the global perchance::global() if you have the std feature enabled:

``rust // Seed the global context first. You may do so manually, or, on platforms that support it, // obtain a seed to pass into it by callingperchance::gentimeseed()`. perchance::seed_global(0x5F3759DF); // ;)

let mut rng = perchance::global(); let between0and1 = rng.uniformf32(); ```

Contributing

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.