Use new AI for computer players
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@448 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
a07e723242
commit
47bf19036e
5 changed files with 220 additions and 192 deletions
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue