Creates a deterministic 32-bit pseudorandom number generator.
Each call advances a private state by 0x9e3779b9. This constant equals
floor(2^32 / phi), where phi is the golden ratio. Addition wraps modulo
2^32. Because the increment is odd, it is coprime to 2^32. The resulting
Weyl sequence visits every 32-bit state once before it repeats.
The mixing function uses the constants 0x21f0aaad and 0x735a2d97 from
the
search
for low avalanche bias. Its XOR-shifts and multiplications by odd integers
are invertible over 32-bit values. The mixer therefore preserves the full
period while diffusing nearby states across the output bits.
Math.imul and the bitwise operators keep the mixing steps in 32-bit
arithmetic. The final unsigned conversion produces an integer from 0 to
2^32 - 1. Dividing by 2^32 maps that integer to [0, 1).
The SplitMix family was introduced by Steele, Lea, and Flood in
Return a uniformly shuffled copy of values using Fisher-Yates.
Runs in O(values.length) time and uses O(values.length) space for the copy.
The input is never mutated.
@throws ― {PrngInvalidInputError} With code INVALID_SOURCE_VALUE when the
random source returns a value outside [0, 1).
shuffled(
functionsplitmix32(seed:number): () =>number
Creates a deterministic 32-bit pseudorandom number generator.
Each call advances a private state by 0x9e3779b9. This constant equals
floor(2^32 / phi), where phi is the golden ratio. Addition wraps modulo
2^32. Because the increment is odd, it is coprime to 2^32. The resulting
Weyl sequence visits every 32-bit state once before it repeats.
The mixing function uses the constants 0x21f0aaad and 0x735a2d97 from
the
search
for low avalanche bias. Its XOR-shifts and multiplications by odd integers
are invertible over 32-bit values. The mixer therefore preserves the full
period while diffusing nearby states across the output bits.
Math.imul and the bitwise operators keep the mixing steps in 32-bit
arithmetic. The final unsigned conversion produces an integer from 0 to
2^32 - 1. Dividing by 2^32 maps that integer to [0, 1).
The SplitMix family was introduced by Steele, Lea, and Flood in
Return a uniformly shuffled copy of values using Fisher-Yates.
Runs in O(values.length) time and uses O(values.length) space for the copy.
The input is never mutated.
@throws ― {PrngInvalidInputError} With code INVALID_SOURCE_VALUE when the
random source returns a value outside [0, 1).
shuffled(
functionsplitmix32(seed:number): () =>number
Creates a deterministic 32-bit pseudorandom number generator.
Each call advances a private state by 0x9e3779b9. This constant equals
floor(2^32 / phi), where phi is the golden ratio. Addition wraps modulo
2^32. Because the increment is odd, it is coprime to 2^32. The resulting
Weyl sequence visits every 32-bit state once before it repeats.
The mixing function uses the constants 0x21f0aaad and 0x735a2d97 from
the
search
for low avalanche bias. Its XOR-shifts and multiplications by odd integers
are invertible over 32-bit values. The mixer therefore preserves the full
period while diffusing nearby states across the output bits.
Math.imul and the bitwise operators keep the mixing steps in 32-bit
arithmetic. The final unsigned conversion produces an integer from 0 to
2^32 - 1. Dividing by 2^32 maps that integer to [0, 1).
The SplitMix family was introduced by Steele, Lea, and Flood in
Adds all the elements of an array separated by the specified separator string.
@param ― separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
Adds all the elements of an array separated by the specified separator string.
@param ― separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
join() // true
constplayers:string[]
players// ['ada', 'grace', 'alan', 'edsger', 'barbara'], the input is untouched
import {
functionsplitmix32(seed:number): () =>number
Creates a deterministic 32-bit pseudorandom number generator.
Each call advances a private state by 0x9e3779b9. This constant equals
floor(2^32 / phi), where phi is the golden ratio. Addition wraps modulo
2^32. Because the increment is odd, it is coprime to 2^32. The resulting
Weyl sequence visits every 32-bit state once before it repeats.
The mixing function uses the constants 0x21f0aaad and 0x735a2d97 from
the
search
for low avalanche bias. Its XOR-shifts and multiplications by odd integers
are invertible over 32-bit values. The mixer therefore preserves the full
period while diffusing nearby states across the output bits.
Math.imul and the bitwise operators keep the mixing steps in 32-bit
arithmetic. The final unsigned conversion produces an integer from 0 to
2^32 - 1. Dividing by 2^32 maps that integer to [0, 1).
The SplitMix family was introduced by Steele, Lea, and Flood in
Return a uniformly shuffled copy of values using Fisher-Yates.
Runs in O(values.length) time and uses O(values.length) space for the copy.
The input is never mutated.
@throws ― {PrngInvalidInputError} With code INVALID_SOURCE_VALUE when the
random source returns a value outside [0, 1).
shuffled(
functionsplitmix32(seed:number): () =>number
Creates a deterministic 32-bit pseudorandom number generator.
Each call advances a private state by 0x9e3779b9. This constant equals
floor(2^32 / phi), where phi is the golden ratio. Addition wraps modulo
2^32. Because the increment is odd, it is coprime to 2^32. The resulting
Weyl sequence visits every 32-bit state once before it repeats.
The mixing function uses the constants 0x21f0aaad and 0x735a2d97 from
the
search
for low avalanche bias. Its XOR-shifts and multiplications by odd integers
are invertible over 32-bit values. The mixer therefore preserves the full
period while diffusing nearby states across the output bits.
Math.imul and the bitwise operators keep the mixing steps in 32-bit
arithmetic. The final unsigned conversion produces an integer from 0 to
2^32 - 1. Dividing by 2^32 maps that integer to [0, 1).
The SplitMix family was introduced by Steele, Lea, and Flood in
Return a uniformly shuffled copy of values using Fisher-Yates.
Runs in O(values.length) time and uses O(values.length) space for the copy.
The input is never mutated.
@throws ― {PrngInvalidInputError} With code INVALID_SOURCE_VALUE when the
random source returns a value outside [0, 1).
shuffled(
functionsplitmix32(seed:number): () =>number
Creates a deterministic 32-bit pseudorandom number generator.
Each call advances a private state by 0x9e3779b9. This constant equals
floor(2^32 / phi), where phi is the golden ratio. Addition wraps modulo
2^32. Because the increment is odd, it is coprime to 2^32. The resulting
Weyl sequence visits every 32-bit state once before it repeats.
The mixing function uses the constants 0x21f0aaad and 0x735a2d97 from
the
search
for low avalanche bias. Its XOR-shifts and multiplications by odd integers
are invertible over 32-bit values. The mixer therefore preserves the full
period while diffusing nearby states across the output bits.
Math.imul and the bitwise operators keep the mixing steps in 32-bit
arithmetic. The final unsigned conversion produces an integer from 0 to
2^32 - 1. Dividing by 2^32 maps that integer to [0, 1).
The SplitMix family was introduced by Steele, Lea, and Flood in
Adds all the elements of an array separated by the specified separator string.
@param ― separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
Adds all the elements of an array separated by the specified separator string.
@param ― separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
join() // true, the seed replays the same order
constplayers:string[]
players[0] // 'player-0', the input is untouched
Nothing in Knotkit seeds itself. Record the seed with the result, and anyone can replay it.