#random #bevy #gamedev #degree #random-access #values #generation

rantz_random

Mostly just a wrapper around fastrand for a bunch of types. Supports bevy and rantz_spatial2d.

12 releases (4 stable)

1.2.1 Jul 20, 2024
1.2.0 Jul 9, 2024
0.4.5 Jun 24, 2024
0.3.7 May 30, 2024

#874 in Game dev

Download history 301/week @ 2024-06-15 174/week @ 2024-06-22 60/week @ 2024-06-29 366/week @ 2024-07-06 59/week @ 2024-07-13 118/week @ 2024-07-20 5/week @ 2024-07-27 46/week @ 2024-09-14 14/week @ 2024-09-21 24/week @ 2024-09-28

84 downloads per month
Used in 2 crates

MIT/Apache

27KB
694 lines

rantz_random

A simple Rust library for generating random values using fastrand. Basically just a fastrand wrapper for a few additional types at the moment. Likely to grow over time. Designed for use with Bevy.

Can generate random values for:

  • i8-128
  • u8-128
  • f32 & f64
  • Vec2/3/4, UVec2/3/4, and IVec2/3/4 (with the bevy feature)
  • Color (with the bevy feature)
  • Degrees, Radians, Position2D, and all the compasses (with the spatial2d feature) - Requires rantz_spatial2d

Can generate random values in a range for:

  • i8-128
  • u8-128
  • f32 & f64
  • Vec2/3/4, UVec2/3/4, and IVec2/3/4 (with the bevy feature)
  • Degrees, Radians, and Position2D (with the spatial2d feature) - Requires rantz_spatial2d

Can shuffle anything Clone + IntoIterator<T> + FromIterator<T> as well as returning a random element, or random index.

Also includes a WeightedTable class for use in weighted random generation.

Usage

Add to your Cargo.toml. Use rantz_random::*; to get access to the traits that define random generation.

Determinism

This crate relies on fastrand which is "deterministic". That is to say, for a given seed value, assuming system order is deterministic, the results will be deterministic.

For gaurenteed determinism, any system that uses the features of this crate will need to be .chain()ed together when added to a Bevy app.

Dependencies

~23MB
~430K SLoC