# `ExVrp.RNG`
[🔗](https://github.com/sephianl/ex_vrp/blob/v0.4.2/lib/ex_vrp/rng.ex#L1)

Random Number Generator (xoshiro128++) for deterministic, reproducible search.

This module provides a functional wrapper around PyVRP's RandomNumberGenerator.
All operations return a new RNG state, preserving immutability.

## Example

    rng = ExVrp.RNG.new(42)
    {rng, value} = ExVrp.RNG.call(rng)
    {rng, float} = ExVrp.RNG.rand(rng)
    {rng, int} = ExVrp.RNG.randint(rng, 100)

# `t`

```elixir
@type t() :: reference()
```

# `call`

```elixir
@spec call(t()) :: {t(), non_neg_integer()}
```

Generates the next random unsigned 32-bit integer.

Returns `{new_rng, value}` where `value` is in the range `[min(), max()]`.

## Example

    {rng, value} = ExVrp.RNG.call(rng)

# `from_state`

```elixir
@spec from_state([non_neg_integer()]) :: {:ok, t()} | {:error, term()}
```

Creates a new RNG from an explicit 4-element state.

## Example

    rng = ExVrp.RNG.from_state([1, 2, 3, 4])

# `max`

```elixir
@spec max() :: non_neg_integer()
```

Returns the maximum value the RNG can produce (2^32 - 1).

# `min`

```elixir
@spec min() :: non_neg_integer()
```

Returns the minimum value the RNG can produce (0).

# `new`

```elixir
@spec new(non_neg_integer()) :: t()
```

Creates a new RNG from a seed.

## Example

    rng = ExVrp.RNG.new(42)

# `rand`

```elixir
@spec rand(t()) :: {t(), float()}
```

Generates a random float uniformly distributed in [0, 1].

Returns `{new_rng, value}`.

## Example

    {rng, float} = ExVrp.RNG.rand(rng)

# `randint`

```elixir
@spec randint(t(), pos_integer()) :: {t(), non_neg_integer()}
```

Generates a random integer in the range [0, high).

Returns `{new_rng, value}`.

## Example

    {rng, value} = ExVrp.RNG.randint(rng, 100)  # value in 0..99

# `state`

```elixir
@spec state(t()) :: [non_neg_integer()]
```

Returns the internal RNG state as a 4-element list.

## Example

    state = ExVrp.RNG.state(rng)  # [a, b, c, d]

---

*Consult [api-reference.md](api-reference.md) for complete listing*
