mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
[Simulated AI] Make printing of the decision tree a bit better.
Also removes a print line from a test.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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."));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user