summaryrefslogtreecommitdiff
path: root/src/com/dabomstew/pkrandom
diff options
context:
space:
mode:
authorcleartonic <cleartonic@gmail.com>2020-01-08 16:39:50 -0600
committercleartonic <cleartonic@gmail.com>2020-01-08 16:39:50 -0600
commitfa4d5a88d67bb057c7d064d10e7ff02ad043258f (patch)
tree08467f971bf3ea4b4e5e878b4b843c3b6aa82daf /src/com/dabomstew/pkrandom
parent7f256f1b0b3088114145cf6c5720bb35c8fef9ca (diff)
distribution: added break on average placement calc loop
Diffstat (limited to 'src/com/dabomstew/pkrandom')
-rwxr-xr-xsrc/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java
index 11a1946..74e78bc 100755
--- a/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java
+++ b/src/com/dabomstew/pkrandom/romhandlers/AbstractRomHandler.java
@@ -3702,10 +3702,12 @@ public abstract class AbstractRomHandler implements RomHandler {
if (usePlacementHistory) {
// System.out.println("Pokemon: "+ chosenPokemon.name + " placement history: " + getPlacementHistory(chosenPokemon) + " current average: " + getPlacementAverage());
- while (getPlacementHistory(chosenPokemon) > getPlacementAverage()) {
- // System.out.println(">> Pokemon: "+ chosenPokemon.name + " exceed threshold, rerolling");
+ int breaknum = 0;
+ while (getPlacementHistory(chosenPokemon) > getPlacementAverage() && breaknum < 100) {
+ System.out.println(">> Pokemon: "+ chosenPokemon.name + " exceed threshold, rerolling");
chosenPokemon = canPick.get(this.random.nextInt(canPick.size()));
- // System.out.println(">> NEW Pokemon: "+ chosenPokemon.name + " placement history: " + getPlacementHistory(chosenPokemon) + " current average: " + getPlacementAverage());
+ System.out.println(">> NEW Pokemon: "+ chosenPokemon.name + " placement history: " + getPlacementHistory(chosenPokemon) + " current average: " + getPlacementAverage());
+ breaknum += 1;
}
}
return chosenPokemon;
@@ -3738,12 +3740,14 @@ public abstract class AbstractRomHandler implements RomHandler {
Pokemon chosenPokemon = canPick.get(this.random.nextInt(canPick.size()));
if (usePlacementHistory) {
- // System.out.println("Pokemon: "+ chosenPokemon.name + " placement history: " + getPlacementHistory(chosenPokemon) + " current average: " + getPlacementAverage());
- while (getPlacementHistory(chosenPokemon) > getPlacementAverage()) {
- // System.out.println(">> Pokemon: "+ chosenPokemon.name + " exceed threshold, rerolling");
- chosenPokemon = canPick.get(this.random.nextInt(canPick.size()));
- // System.out.println(">> NEW Pokemon: "+ chosenPokemon.name + " placement history: " + getPlacementHistory(chosenPokemon) + " current average: " + getPlacementAverage());
- }
+ System.out.println("Pokemon: "+ chosenPokemon.name + " placement history: " + getPlacementHistory(chosenPokemon) + " current average: " + getPlacementAverage());
+ int breaknum = 0;
+ while (getPlacementHistory(chosenPokemon) > getPlacementAverage() && breaknum < 100) {
+ System.out.println(">> Pokemon: "+ chosenPokemon.name + " exceed threshold, rerolling");
+ chosenPokemon = canPick.get(this.random.nextInt(canPick.size()));
+ System.out.println(">> NEW Pokemon: "+ chosenPokemon.name + " placement history: " + getPlacementHistory(chosenPokemon) + " current average: " + getPlacementAverage());
+ breaknum += 1;
+ }
}
return chosenPokemon;
} else {