[Simulated AI] Make printing of the decision tree a bit better.

Also removes a print line from a test.
This commit is contained in:
Myrd
2016-12-29 18:22:31 +00:00
parent 1880fc6df1
commit c3f30c6871
4 changed files with 24 additions and 9 deletions

View File

@@ -43,6 +43,7 @@ public class Plan {
final Score initialScore;
final String sa;
final String saHumanStr;
PossibleTargetSelector.Targets targets;
String choice;
int[] modes;
@@ -52,14 +53,16 @@ public class Plan {
this.initialScore = initialScore;
this.prevDecision = prevDecision;
this.sa = sa.toString();
this.saHumanStr = SpellAbilityPicker.abilityToString(sa);
this.targets = null;
this.choice = null;
}
public Decision(Score initialScore, Decision prevDecision, String saString) {
public Decision(Score initialScore, Decision prevDecision, String saString, String saHumanStr) {
this.initialScore = initialScore;
this.prevDecision = prevDecision;
this.sa = saString;
this.saHumanStr = saHumanStr;
this.targets = null;
this.choice = null;
}
@@ -68,6 +71,7 @@ public class Plan {
this.initialScore = initialScore;
this.prevDecision = prevDecision;
this.sa = null;
this.saHumanStr = null;
this.targets = targets;
this.choice = null;
}
@@ -76,6 +80,7 @@ public class Plan {
this.initialScore = initialScore;
this.prevDecision = prevDecision;
this.sa = null;
this.saHumanStr = null;
this.targets = null;
this.choice = choice.getName();
}
@@ -84,26 +89,35 @@ public class Plan {
this.initialScore = initialScore;
this.prevDecision = prevDecision;
this.sa = null;
this.saHumanStr = null;
this.targets = null;
this.choice = null;
this.modes = modes;
this.modesStr = modesStr;
}
@Override
public String toString() {
public String toString(boolean showHostCard) {
StringBuilder sb = new StringBuilder();
sb.append("[initScore=").append(initialScore).append(" ");
if (!showHostCard) {
sb.append("[initScore=").append(initialScore).append(" ");
}
if (modesStr != null) {
sb.append(modesStr);
} else {
sb.append(sa);
sb.append(showHostCard ? saHumanStr : sa);
}
if (targets != null) {
sb.append(" (targets: ").append(targets).append(")");
}
sb.append("]");
if (!showHostCard) {
sb.append("]");
}
return sb.toString();
}
@Override
public String toString() {
return toString(false);
}
}
}

View File

@@ -143,7 +143,7 @@ public class SimulationController {
d = d.prevDecision;
}
Plan.Decision merged = new Plan.Decision(d.initialScore, d.prevDecision, d.sa);
Plan.Decision merged = new Plan.Decision(d.initialScore, d.prevDecision, d.sa, d.saHumanStr);
merged.targets = targets;
merged.choice = choice;
merged.modes = modes;
@@ -252,7 +252,7 @@ public class SimulationController {
System.err.print(" ");
String str;
if (useStack && !currentStack.isEmpty()) {
str = getLastMergedDecision().toString();
str = getLastMergedDecision().toString(true);
} else {
str = SpellAbilityPicker.abilityToString(origSa);
}

View File

@@ -348,6 +348,8 @@ public class SpellAbilityPicker {
for (AbilitySub sub : result) {
if (sb.length() > 0) {
sb.append(" ");
} else {
sb.append(sub.getHostCard()).append(" -> ");
}
sb.append(sub);
}

View File

@@ -670,7 +670,6 @@ public class GameSimulatorTest extends TestCase {
assertEquals(1, scionCopy.getNetPower());
assertEquals(1, scionCopy.getNetToughness());
assertTrue(scionCopy.isSick());
System.err.println("Search continues on: " + scionCopy);
assertNotNull(findSAWithPrefix(scionCopy, "Sacrifice CARDNAME: Add {C} to your mana pool."));
}