# std.random

Pseudo-random values from a global xoshiro256++ generator.

```tea
use random from "std.random"
```

Examples may be fragments requiring the module import or additional setup.

## std.random.seed

```tea
pub def seed(value: Int) -> Void
```

Deterministically reseed the global generator.

```tea
use random from "std.random"

random.seed(42)
const first = random.between(1, 6)
random.seed(42)
@println(first == random.between(1, 6)) # true
```

## std.random.float

```tea
pub def float() -> Float
```

Return a uniform random Float in [0, 1).

```tea
use random from "std.random"

const value = random.float()
@println(value >= 0.0 && value < 1.0) # true
```

## std.random.between

```tea
pub def between(min: Int, max: Int) -> Int
```

Return a uniform random Int between min and max, inclusive.

```tea
use random from "std.random"

const roll = random.between(1, 6)
@println(roll) # An integer from 1 through 6
```

## std.random.flip

```tea
pub def flip() -> Bool
```

Return true or false with equal probability.

```tea
use random from "std.random"

@println(if (random.flip()) "heads" else "tails")
```

## std.random.chance

```tea
pub def chance(probability: Float) -> Bool
```

Return true with the given probability (0.0 never, 1.0 always).

```tea
use random from "std.random"

if random.chance(0.25)
  @println("Bonus round!")
end
```

## std.random.bytes

```tea
pub def bytes(count: Int) -> List[Int]
```

Return a list of uniform random bytes (0-255).

```tea
use random from "std.random"

const bytes = random.bytes(16)
@println(@len(bytes)) # 16
```

## std.random.choice

```tea
pub def choice[T](items: List[T]) -> T
```

Return a uniformly chosen element of a non-empty list.

```tea
use random from "std.random"

@println(random.choice(["tea", "coffee", "water"])) # One of these drinks
```

## std.random.shuffle

```tea
pub def shuffle[T](items: List[T]) -> List[T]
```

Return a new list with the elements in uniformly random order.

```tea
use random from "std.random"

const players = ["Ada", "Ben", "Cam"]
const order = random.shuffle(players)
@println(order) # A random ordering
@println(players) # [Ada, Ben, Cam] (unchanged)
```

## std.random.uuid_v4

```tea
pub def uuid_v4() -> String
```

Return a random UUID (version 4, variant 1) as lowercase hex.

```tea
use random from "std.random"

@println(random.uuid_v4()) # A new version-4 UUID
```
