Revert "Merge branch 'temp_dev6' into 'master'"

This reverts merge request !499
This commit is contained in:
Sol
2018-05-01 01:11:29 +00:00
parent 64e8dd35c2
commit 1a3308017a
19 changed files with 22 additions and 49 deletions

View File

@@ -34,27 +34,22 @@ public class MyRandom {
private static Random random = new SecureRandom();
/**
* Changes into a non-CSPRNG, which can be seeded for use in tests/repeatable experiments.
*/
public static void setSeed(int seed) {
System.out.println("Setting the RNG seed to: " + seed);
random = new Random(seed);
}
/**
* Returns True with Percent probability.
* <p>
* percentTrue.<br>
* If percent is like 30, then 30% of the time it will be true.
* </p>
*
* TODO: My guess is no one is passing in a number scaled to 100. This API should probably be cut.
* @param percent
* a int.
* @return a boolean.
*/
public static boolean percentTrue(final long percent) {
return percent > MyRandom.getRandom().nextDouble() * 100;
public static boolean percentTrue(final int percent) {
return percent > MyRandom.getRandom().nextInt(100);
}
/**
* Gets the random.
*
* TODO: Make this private, and instead add a robust set of APIs here.
*
* @return the random
*/
public static Random getRandom() {
@@ -65,7 +60,7 @@ public class MyRandom {
int[] groups = new int[numGroups];
for (int i = 0; i < value; i++) {
groups[MyRandom.getRandom().nextInt(numGroups)]++;
groups[random.nextInt(numGroups)]++;
}
return groups;