A string of characters that are all the same used as a seed, no matter the length, results in the same output.
ChildishGiant opened this issue · 2 comments
ChildishGiant commented
Math.seedrandom("a")
Math.random() -> 0.43449421599986604
Math.seedrandom("aa")
Math.random() -> 0.43449421599986604
Math.seedrandom("aaaaaaa")
Math.random() -> 0.43449421599986604
davidbau commented
From the readme:
The standard ARC4 key scheduler cycles short keys, which means that seedrandom('ab') is equivalent to seedrandom('abab') and 'ababab'. Therefore it is a good idea to add a terminator to avoid trivial equivalences on short string seeds, e.g., Math.seedrandom(str + '\0'). Starting with version 2.0, a terminator is added automatically for non-string seeds, so seeding with the number 111 is the same as seeding with '111\0'.
In the interest of compatibility, we are staying with this scheme.
ChildishGiant commented
Okay, thanks for the explanation 😄