diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-03 15:33:43 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-12-03 16:25:59 +0100 |
commit | 13844dd585675b6b92ca0671d5c446693fbb04c8 (patch) | |
tree | b30a2db12515c9e62c934eaf5994a05c172b9c45 | |
parent | 4d19bd25fbbb95709d638b3cc75288ce470034dc (diff) | |
download | julius-caesar-13844dd585675b6b92ca0671d5c446693fbb04c8.tar.gz |
Change PRNG to BigInt version.
-rw-r--r-- | rules.js | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -61,7 +61,11 @@ const RESERVE_MARK = "" let game = null function random(n) { - return (game.seed = game.seed * 200105 % 34359738337) % n + // Largest MLCG that will fit its state in a double. + // Uses BigInt for arithmetic, so is an order of magnitude slower. + // https://www.ams.org/journals/mcom/1999-68-225/S0025-5718-99-00996-5/S0025-5718-99-00996-5.pdf + // m = 2**53 - 111 + return (game.seed = Number(BigInt(game.seed) * 5667072534355537n % 9007199254740881n)) % n } function logbr() { |