Rng class

The Random Number God: deliverer of good and ill fortune alike.

Constructors

Rng(int seed)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

countFromFloat(double range) int
Gets a random integer count within the given floating point range.
float([double? minOrMax, double? max]) double
Gets a random floating-point value within the given range.
inclusive(int minOrMax, [int? max]) int
Gets a random int within a given range. If max is given, then it is in the range [minOrMax, max]. Otherwise, it is [0, minOrMax]. In other words, inclusive(2) returns a 0, 1, or 2, and inclusive(2, 4) returns 2, 3, or 4.
item<T>(List<T> items) → T
Gets a random item from the given list.
normal() double
Calculate a random number with a normal distribution.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
oneIn(int chance) bool
Returns true if a random int chosen between 1 and chance was 1.
percent(int chance) bool
Returns true chance percent of the time.
range(int minOrMax, [int? max]) int
Gets a random int within a given range. If max is given, then it is in the range [minOrMax, max). Otherwise, it is [0, minOrMax). In other words, range(3) returns a 0, 1, or 2, and range(2, 5) returns 2, 3, or 4.
round(double value) int
Rounds value to a nearby integer, randomly rounding up or down based on the fractional value.
setSeed(int seed) → void
Resets the random number generator's internal state to seed.
shuffle<T>(List<T> items) → void
Randomly re-orders elements in items.
take<T>(List<T> items) → T
Removes a random item from the given list.
takeOrdered<T>(List<T> items) → T
Removes a random item from the given list, preserving the order of the remaining items.
taper(int start, int chanceOfIncrement) int
toString() String
A string representation of this object.
inherited
triangleInt(int center, int range) int
Gets a random number centered around center with range (inclusive) using a triangular distribution. For example triangleInt(8, 4) will return values between 4 and 12 (inclusive) with greater distribution towards 8.
vecInRect(Rect rect) Vec
Gets a random Vec within the given Rect (half-inclusive).

Operators

operator ==(Object other) bool
The equality operator.
inherited