summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-03 15:33:43 +0100
committerTor Andersson <tor@ccxvii.net>2023-12-03 16:25:59 +0100
commit13844dd585675b6b92ca0671d5c446693fbb04c8 (patch)
treeb30a2db12515c9e62c934eaf5994a05c172b9c45
parent4d19bd25fbbb95709d638b3cc75288ce470034dc (diff)
downloadjulius-caesar-13844dd585675b6b92ca0671d5c446693fbb04c8.tar.gz
Change PRNG to BigInt version.
-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() {