summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js6
1 files changed, 5 insertions, 1 deletions
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() {