From 13844dd585675b6b92ca0671d5c446693fbb04c8 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 3 Dec 2023 15:33:43 +0100 Subject: Change PRNG to BigInt version. --- rules.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rules.js b/rules.js index fcdc1ec..a44fd4f 100644 --- a/rules.js +++ b/rules.js @@ -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() { -- cgit v1.2.3