Random

Random related methods


srl.GaussRand

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

Generates a random gaussian/normal number.


srl.TruncatedGauss

function TSRL.TruncatedGauss(Left:Double=0; Right:Double=1): Double;

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


srl.SkewedRand

function TSRL.SkewedRand(Mode, Lo, Hi: Double): Double; static;

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


srl.NormalRange

function TSRL.NormalRange(min, max: Int64): Int64;

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


srl.NormalRange

function TSRL.NormalRange(Min, Max: Double): Double;

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


srl.RandomPoint

function TSRL.RandomPoint(Mean: TPoint; MaxRad: Int32): TPoint;

Generates a random TPoint which weights around Mean, with a max distance from mean defined by MaxRad.


srl.RandomPoint (overload)

function TSRL.RandomPoint(Bounds: TBox): TPoint; overload;

Generates a random TPoint in the bounds of the given box Bounds, the point weights towards the middle of the box.


srl.RandomPoint (overload)

function TSRL.RandomPoint(Rect: TRectangle): TPoint; overload;

Generates a random TPoint in the given rectangle Rect, The point weights towards the middle of the rectangle.


srl.RandonPointEx

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

srl.rowp

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…


srl.Dice

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

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

Example:

pascal::
if srl.Dice(10.5) then
WriteLn(‘This has a 10.5 percent chance of writing’)
else
WriteLn(‘No dice’);

Wait (overload)

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

Waits … Weighted towards the mean of Min and Max


WaitEx

procedure WaitEx(Mean, Dev: Double);

Waits … Regular gauss random