This library has been optimized for Burst and ECS or DOTS, but can also be used with C# and IL2CPP directly. The
interface is very similar to typical random number generator interface, with methods like NextInt
, NextFloat
among others.
Various other types of random number generators are provided. To get started the GRandom
RNG can be used, it
provides a good tradeoff between performance and quality. All RNGs implement the same interface (minor differences for
32bit RNGs which output less random bits on every iteration) and can be easily switched.
Good practice is to use the using
statement like this
using RNG = GeneralRandom.PseudoRandom.GRandom;
//...
var rng = new RNG(<seed>);
in this case the RNG variant can be easily switched as the API is the same (except for 32 bit variants, which are missing
the ...Fast
methods). This also works inside burst without issues.
The next important steps are reading Working with Structs and Seeds. A method overview can be found here and available distributions here.