Skip to content
Ricky Setiawan edited this page Mar 3, 2021 · 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); // select 2 numbers (elements) from items array.

OR

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

IRNG rng = new Xoroshiro128plus();
rng.Choice(items); // select only 1 number (element) from items array.

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);