[Simulated AI] Fix game copy error caused by marked damage not being copied.

Since marked damage affects attack/block decisions and this is used for scoring, it resulted in a different score being computed in the sub game, triggering a copy error.

Adds a test.

Also fixes creature power evaluation copy paste error.
This commit is contained in:
Myrd
2016-12-27 19:11:18 +00:00
parent 7f05f08efc
commit 8f64ad3638
3 changed files with 12 additions and 6 deletions

View File

@@ -35,7 +35,7 @@ public class CreatureEvaluator implements Function<Card, Integer> {
}
}
value += addValue(power * 15, "power");
value += addValue(toughness * 10, "toughness");
value += addValue(toughness * 10, "toughness: " + toughness);
value += addValue(c.getCMC() * 5, "cmc");
// Evasion keywords

View File

@@ -258,6 +258,7 @@ public class GameCopier {
newCard.setSemiPermanentPowerBoost(c.getSemiPermanentPowerBoost());
newCard.addTempToughnessBoost(c.getTempToughnessBoost());
newCard.setSemiPermanentToughnessBoost(c.getSemiPermanentToughnessBoost());
newCard.setDamage(c.getDamage());
newCard.setChangedCardTypes(c.getChangedCardTypes());
newCard.setChangedCardKeywords(c.getChangedCardKeywords());

View File

@@ -36,6 +36,14 @@ public class GameStateEvaluator {
return combat;
}
private static String cardToString(Card c) {
String str = c.getName();
if (c.isCreature()) {
str += " " + c.getNetPower() + "/" + c.getNetToughness();
}
return str;
}
public Score getScoreForGameState(Game game, Player aiPlayer) {
if (game.isGameOver()) {
return game.getOutcome().getWinningPlayer() == aiPlayer ? new Score(Integer.MAX_VALUE) : new Score(Integer.MIN_VALUE);
@@ -84,10 +92,7 @@ public class GameStateEvaluator {
if (gamePhase.isBefore(PhaseType.MAIN2) && c.isSick() && c.getController() == aiPlayer) {
summonSickValue = 0;
}
String str = c.getName();
if (c.isCreature()) {
str += " " + c.getNetPower() + "/" + c.getNetToughness();
}
String str = cardToString(c);
if (c.getController() == aiPlayer) {
debugPrint(" Battlefield: " + str + " = " + value);
score += value;
@@ -149,7 +154,7 @@ public class GameStateEvaluator {
@Override
protected int getEffectivePower(final Card c) {
if (ignoreTempBoosts) {
Card.StatBreakdown breakdown = c.getNetToughnessBreakdown();
Card.StatBreakdown breakdown = c.getNetCombatDamageBreakdown();
return breakdown.getTotal() - breakdown.tempBoost;
}
return c.getNetCombatDamage();