Aego Playground

aego/randmodule

Boolfunction

func Bool() bool

Bool returns true or false with equal chance.

Example

flip := rand.Bool()

Floatfunction

func Float() float

Float returns a random number in [0, 1).

Example

if rand.Float() < 0.25 {
	dropLoot()
}

Intfunction

func Int(min int, max int) int

Int returns a random int in [min, max). It returns min when max <= min.

Example

roll := rand.Int(1, 7)

Rangefunction

func Range(min float, max float) float

Range returns a random float in [min, max).

Example

delay := rand.Range(0.5, 1.5)

Seedfunction

func Seed() int

Seed returns the seed of the world's generator. Replays with the same seed produce the same numbers.

Example

log.Info("seed " + string(rand.Seed()))