Random related methods.


function nzRandom(): Double;

Generates a random number that is never 0.


function TSRL.GaussRand(Mean, Dev: Double): Double;

Generates a random gaussian/normal number.


function TSRL.TruncatedGauss(Left:Double=0; Right:Double=1; CUTOFF:Single=0): Double; static;
function TSRL.TruncatedGauss(Left:Int64=0; Right:Int64=1; CUTOFF:Single=0): Int64; static; overload;

Generates a random gaussian/normal number which is truncated and mapped within then given range [left..right] weighted towards left


function TSRL.SkewedRand(Mode, Lo, Hi: Double; CUTOFF:Single=0): Double; static;
function TSRL.SkewedRand(Mode, Lo, Hi: Int64; CUTOFF:Single=0): Int64; static; overload;

Random skewed distribution generation. Mode is a number between Lo and Hi which is where the most of the generated numbers will land.


function TSRL.NormalRange(Min, Max: Double; CUTOFF:Single=0): Double; constref;
function TSRL.NormalRange(Min, Max: Int64; CUTOFF:Single=0): Int64; constref; overload;

Generates a random float or integer in the given range, weighted towards the mean.


function TSRL.RandomPoint(Mean: TPoint; MaxRad: Int32): TPoint;
function TSRL.RandomPoint(Bounds: TBox): TPoint; overload;
function TSRL.RandomPoint(Rect: TRectangle): TPoint; overload;

Generates a random TPoint which weights around Mean, with a max distance from mean defined by MaxRad. If a TBox or a TRectangle are passed, the mean point of those will be used.


function TSRL.RandonPointEx(From: TPoint; B: TBox; Force: Double=0.35): TPoint; constref;

Generates a random point within the bounds of the given box B, the point generated is skewed towards towards the From-point. The last parameter Force defines how much the generated point is to be skewed towards or away from From - Expects value in the range 0..2

  • Force = 0: Result weighs heavily towrads the edge closest to From

  • Force = 1: Result in the middle of box is most common

  • Force = 2: Result weighs heavily towrads the edge furthest away from From


function TSRL.rowp(From: TPoint; Rect: TRectangle; Force: Double=-0.9; Smoothness: Double=PI/12): TPoint;
function TSRL.rowp(From: TPoint; Box: TBox; Force: Double=-0.9; Smoothness: Double=PI/12): TPoint;

ROWP, short for Random Olly Weighted Point. Generates a random point based on a rough formula that Olly came up with for weighting points towards “From” point. Final implementation and math done by slacky.

Force ranges from -1 (close to) to 1 (away from), where 0 is mean, but with a bit of a skewiness…


function TSRL.Dice(ChancePercent: Double): Boolean; static;

Generates a random number and returns True whenever the value generated is within the chance (in percentage).


if SRL.Dice(10.5) then
  WriteLn('This has a 10.5 percent chance of writing')
  WriteLn('No dice');


procedure Wait(Min, Max: Double; Weight: EWaitDir=wdMean); overload;

Waits … Weighted towards the mean of Min and Max


procedure WaitEx(Mean, Dev: Double);

Waits … Regular gauss random