node フォルダの README を参照してください
java.util.Random の nextDouble から生成された double が与えられた場合、同じ状態を持つ Random を再現します。この ReplicatedRandom は、元の Random の将来の値を予測するために使用できます。
例:
Random r = new Random();
ReplicatedRandom rr = new ReplicatedRandom();
rr.replicateState(r.nextDouble());
System.out.println(r.nextDouble() == rr.nextDouble()); // True
System.out.println(r.nextDouble() == rr.nextDouble()); // True
System.out.println(r.nextDouble() == rr.nextDouble()); // True
Math.random() でも同様に機能します(内部で Random を使用しているため):
ReplicatedRandom rr = new ReplicatedRandom();
rr.replicateState(Math.random());
System.out.println(Math.random() == rr.nextDouble()); // True
System.out.println(Math.random() == rr.nextDouble()); // True
System.out.println(Math.random() == rr.nextDouble()); // True
nextInt() でも同様に機能しますが、連続する2つの値が必要です:
Random r = new Random();
ReplicatedRandom rr = new ReplicatedRandom();
rr.replicateState(r.nextInt(), r.nextInt());
System.out.println(r.nextInt() == rr.nextInt()); // True
System.out.println(r.nextInt() == rr.nextInt()); // True
System.out.println(r.nextInt() == rr.nextInt()); // True
詳細は、この ブログ投稿 を参照してください。