API Reference › Hash › Hash.mix
method

Hash.mix

Hash.mix(x) -> int

Scrambles a single integer so its bits are thoroughly mixed — the MurmurHash3 fmix32 finalizer (shift/multiply/shift). Nearby inputs like 0, 1, 2 map to values that look unrelated, which is exactly what you want when turning a counter, entity id, or frame number into a random-looking seed. It is deterministic and self-inverse-free: the same input always gives the same output. Hash.mix(0) is 0. For folding several numbers together use Hash.combine.

Parameters

xthe integer to avalanche

Example

program Seeds {
  entry {
    var i = 0
    while i < 4 {
      print(Hash.mix(i))   # consecutive counters -> unrelated-looking seeds
      i = i + 1
    }
  }
}
← All symbols