From 3f372180e60458860e35d597a35799230ccb7175 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 4 Apr 2021 12:33:52 -0300 Subject: [PATCH] increased store for random seeds to 64k --- docs/scarpet/language/SystemFunctions.md | 11 ++++++----- src/main/java/carpet/script/ScriptHost.java | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/scarpet/language/SystemFunctions.md b/docs/scarpet/language/SystemFunctions.md index eb453bcd..1ddcc8e9 100644 --- a/docs/scarpet/language/SystemFunctions.md +++ b/docs/scarpet/language/SystemFunctions.md @@ -227,11 +227,12 @@ length('foo') => 3 ### `rand(expr), rand(expr, seed)` returns a random number from `0.0` (inclusive) to `expr` (exclusive). In boolean context (in conditions, -boolean functions, or `bool`), returns false if the randomly selected value is less than 1\. This means -that `rand(2)` returns true half of the time and `rand(5)` returns true for 80% (4/5) of the time. If seed is not -provided, uses a random seed. If seed is provided, each consecutive call to rand() will act like 'next' call to the -same random object. Scarpet keeps track of up to 1024 custom random number generators, so if you exceed this number -(per app), then your random sequence will revert to the beginning. +boolean functions, or `bool`), returns false if the randomly selected value is less than 1. This means +that `bool(rand(2))` returns true half of the time and `!rand(5)` returns true for 20% (1/5) of the time. If seed is not +provided, uses a random seed that's shared across all scarpet apps. +If seed is provided, each consecutive call to rand() will act like 'next' call to the +same random object. Scarpet keeps track of up to 65536 custom random number generators (custom seeds, per app), +so if you exceed this number, your random sequences will revert to the beginning and start over.
 map(range(10), floor(rand(10))) => [5, 8, 0, 6, 9, 3, 9, 9, 1, 8]
diff --git a/src/main/java/carpet/script/ScriptHost.java b/src/main/java/carpet/script/ScriptHost.java
index 255f76d4..f57ae663 100644
--- a/src/main/java/carpet/script/ScriptHost.java
+++ b/src/main/java/carpet/script/ScriptHost.java
@@ -37,7 +37,7 @@ public abstract class ScriptHost
 
     public Random getRandom(long aLong)
     {
-        if (randomizers.size() > 1024)
+        if (randomizers.size() > 65536)
             randomizers.clear();
         return randomizers.computeIfAbsent(aLong, Random::new);
     }