diff options
Diffstat (limited to 'src/jrummikub/ai')
-rw-r--r-- | src/jrummikub/ai/TurnLogic.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/jrummikub/ai/TurnLogic.java b/src/jrummikub/ai/TurnLogic.java index 01a3d59..b9e2a2a 100644 --- a/src/jrummikub/ai/TurnLogic.java +++ b/src/jrummikub/ai/TurnLogic.java @@ -27,9 +27,10 @@ public class TurnLogic { private State top; private volatile boolean abort = false; + private volatile boolean autoAbort = false; private int neededPoints = 0; - private double neededScore = Double.NEGATIVE_INFINITY; + private double neededScore = 0; @SuppressWarnings("serial") private static class Contradiction extends Throwable { @@ -548,6 +549,10 @@ public class TurnLogic { public List<StoneSet> getResult() { State result = bestState; + if (result == null) { + return null; + } + ArrayList<StoneSet> outputSets = new ArrayList<StoneSet>(); for (int i = 0; i < stoneCount; i++) { @@ -560,9 +565,6 @@ public class TurnLogic { && isNullSet(stone.rightGroup)) { break; } - /* System.out.println("--"); - System.out.println(stone.rightRun); - System.out.println(stone.rightGroup); */ Integer rightRunID = stone.rightRun.iterator().next(); Integer rightGroupID = stone.rightGroup.iterator().next(); @@ -600,7 +602,7 @@ public class TurnLogic { } public double optimize() { - while (solve()) { + while (!autoAbort && solve()) { neededScore = top.getScore(); } return neededScore; @@ -688,4 +690,12 @@ public class TurnLogic { // This should never happen throw new Error("Internal AI error"); } + + public void autoAbort() { + if (bestState != null) { + abort = true; + } + autoAbort = true; + + } } |