Skip to content

Commit

Permalink
Improve variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
oblonski committed Feb 14, 2025
1 parent 775e098 commit 287c5ce
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ private void updateSumWeights() {
public SearchStrategy getRandomStrategy() {
if (random == null)
throw new IllegalStateException("randomizer is null. make sure you set random object correctly");
double randomFig = random.nextDouble();
double sumProbabilities = 0.0;
double randomValue = random.nextDouble();
double cumulativeProbability = 0.0;
for (int i = 0; i < weights.size(); i++) {
sumProbabilities += weights.get(i) / sumWeights;
if (randomFig < sumProbabilities) {
cumulativeProbability += weights.get(i) / sumWeights;
if (randomValue < cumulativeProbability) {
return strategies.get(i);
}
}
throw new IllegalStateException("no search-strategy found");
return strategies.get(strategies.size() - 1);
}

public void addSearchStrategyListener(SearchStrategyListener strategyListener) {
Expand Down

0 comments on commit 287c5ce

Please sign in to comment.