Skip to content

Commit

Permalink
changed how smallest field group is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Jan 3, 2015
1 parent 77de281 commit 577efca
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/net/zomis/minesweeper/analyze/GameAnalyze.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private double solveRules(List<Solution<T>> solutions) {
if (this.rules.isEmpty())
return 0;

FieldGroup<T> chosenGroup = this.rules.get(0).getSmallestFieldGroup();
FieldGroup<T> chosenGroup = getSmallestFieldGroup();
if (chosenGroup == null) {
throw new IllegalStateException("Chosen group is null.");
}
Expand All @@ -89,5 +89,15 @@ private double solveRules(List<Solution<T>> solutions) {
}
return total;
}

private FieldGroup<T> getSmallestFieldGroup() {
for (FieldRule<T> rule : rules) {
FieldGroup<T> smallest = rule.getSmallestFieldGroup();
if (smallest != null) {
return smallest;
}
}
return null;
}

}

0 comments on commit 577efca

Please sign in to comment.