Random

Random related methods.


SRL.RandomPoint

function SRL.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

function SRL.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

function SRL.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 SRL.RandonPointEx(From: TPoint; B: TBox; Force: Double=0.35): TPoint;

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 SRL.rowp(From: TPoint; Rect: TRectangle; Force: Double=-0.9; Smoothness: Double=PI/12): TPoint; function SRL.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 SRL.Dice(ChancePercent: Double): Boolean; static;

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

Example:

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

Wait

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

Waits … Weighted towards the mean of Min and Max


WaitEx

procedure WaitEx(Mean, Dev: Double);

Waits … Regular gauss random