# aego/rand

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

`Int(min, max)` and `Range(min, max)` include `min` and exclude `max`. Every script of a world draws from the same generator, so the numbers a script gets depend on the order of calls in the frame. The documentation sandbox always runs with seed 1.

## Example

```aes run
package demo

import (
    "aego/log"
    "aego/rand"
)

script Loot {
    @export var DropChance float = 0.5

    func Ready() {
        log.Info("seed " + string(rand.Seed()))
        for i := 0; i < 5; i++ {
            roll := rand.Int(1, 7)
            if rand.Float() < DropChance {
                gold := rand.Int(5, 20)
                log.Info("chest " + string(i) + ": rolled " + string(roll) + ", drops " + string(gold) + " gold")
            } else {
                log.Info("chest " + string(i) + ": rolled " + string(roll) + ", empty")
            }
        }
        delay := rand.Range(0.5, 1.5)
        log.Info("next spawn in " + string(delay) + " s, facing left: " + string(rand.Bool()))
    }
}
```

## Bool

```
func Bool() bool
```

Returns true or false with equal chance.

## Float

```
func Float() float
```

Returns a random number in [0, 1).

## Int

```
func Int(min int, max int) int
```

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

## Range

```
func Range(min float, max float) float
```

Returns a random float in [min, max).

## Seed

```
func Seed() int
```

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