From 47bf19036e049787fa7742f5ff72a08a0c9e887c Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Fri, 17 Jun 2011 22:12:41 +0200 Subject: Use new AI for computer players git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@448 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/ai/TurnLogic.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/jrummikub/ai') 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 getResult() { State result = bestState; + if (result == null) { + return null; + } + ArrayList outputSets = new ArrayList(); 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; + + } } -- cgit v1.2.3