Skip to content
Ricky Setiawan edited this page Dec 2, 2020 · 4 revisions

The simple way to use

Get random uint or unsigned 32-bit integer

var rng = new Xoroshiro128plus();
var randomInt = rng.NextInt();

OR

IRNG rng = new Xoroshiro128plus();
var randomInt = rng.NextInt();

Get random ulong or unsigned 64-bit integer

IRNG rng = new Xoroshiro128plus();
var randomUlong = rng.NextLong();

Get a random choice

var items = int[] { 1, 2, 3, 4, 5 };

IRNG rng = new Xoroshiro128plus();
rng.Choice(items, 2);

OR

var items = int[] { 1, 2, 3, 4, 5 };

IRNG rng = new Xoroshiro128plus();
rng.Choice(items);

Get a k distinct element from the array

var items = int[] { 1, 2, 3, 4, 5 };

IRNG rng = new Xoroshiro128plus();
rng.Sample(items, 2);

Shuffle an array

var items = int[] { 1, 2, 3, 4, 5 };

IRNG rng = new Xoroshiro128plus();
rng.Shuffle(items);
Clone this wiki locally