From: JBM Date: Thu, 4 Jun 2020 14:10:38 +0000 (+0200) Subject: HTML for salting the seed X-Git-Url: https://troll.desast.re/troll.git/commitdiff_plain/734e04c8106926949ce97c993e065c98f0fd25ed?ds=inline;hp=7b8732a6aba5c34e24aa324a25e2fae37f7149a7 HTML for salting the seed --- diff --git a/PLAN.org b/PLAN.org index 6db6e52..613c3a6 100644 --- a/PLAN.org +++ b/PLAN.org @@ -49,7 +49,7 @@ That one's probably never going to be DONE ^^' * DONE initial model parametrization * DONE view parameterization? * DONE troll races -* TODO html for salting the seed +* DONE html for salting the seed * BUGS ** viewer goes blank <2020-06-03 mer. 22:58> (22:19:12) Astrobytes: JBM, if you're around, the TVC viewer goes blank after a couple of games. Consistently. In Chrome. Other games not doing the same. diff --git a/config/statement_en.html b/config/statement_en.html index b5f784b..a63199a 100644 --- a/config/statement_en.html +++ b/config/statement_en.html @@ -207,6 +207,37 @@ +
+

+   + Proper RNG seeding examples +

+ + + + + + + + + + + + + + + + + +
Language FamilySample
JVM + long mySecretSalt = 0x4242424242424242L;
+ Random random = new Random(gameSeed ^ gameSide ^ mySecretSalt); +
C, C++, Perl… + srand(gameSeed ^ gameSide ^ 0xdeadb33f);
+ std::srand(gameSeed ^ gameSide ^ 12345);
+ srand( $gameSeed ^ $gameSide ^ 0xCAFE_BABE ); +
OtherUnachievable until proven otherwise
+

  diff --git a/src/test/java/PlayerRand.java b/src/test/java/PlayerRand.java index 4dc9103..a29f16d 100644 --- a/src/test/java/PlayerRand.java +++ b/src/test/java/PlayerRand.java @@ -11,11 +11,14 @@ public class PlayerRand { }; public static void main(String[] args) { Scanner in = new Scanner(System.in); - Random random = new Random(); int roadLength = in.nextInt(); int initialStones = in.nextInt(); + long gameSeed = in.nextLong(); + int gameSide = in.nextInt(); in.nextLine(); + long mySecretSalt = 0x4242424242424242L; + Random random = new Random(gameSeed ^ gameSide ^ mySecretSalt); while (true) { int trollDistance = in.nextInt();