- AI tweak to be a little more aggressive when a burn spell/ability is available.

This commit is contained in:
Sloth
2013-05-26 20:20:31 +00:00
parent f8fb5fef22
commit 3eb9aed797
2 changed files with 40 additions and 4 deletions

View File

@@ -422,7 +422,7 @@ public class AiAttackController {
} }
unblockedAttackers.addAll(remainingAttackers); unblockedAttackers.addAll(remainingAttackers);
if ((ComputerUtilCombat.sumDamageIfUnblocked(remainingAttackers, opp) >= opp.getLife()) if (ComputerUtilCombat.sumDamageIfUnblocked(remainingAttackers, opp) + ComputerUtil.possibleNonCombatDamage(ai) >= opp.getLife()
&& !((opp.cantLoseForZeroOrLessLife() || ai.cantWin()) && (opp.getLife() < 1))) { && !((opp.cantLoseForZeroOrLessLife() || ai.cantWin()) && (opp.getLife() < 1))) {
return true; return true;
} }
@@ -620,14 +620,13 @@ public class AiAttackController {
candidateUnblockedDamage += ComputerUtilCombat.damageIfUnblocked(pCard, opp, null); candidateUnblockedDamage += ComputerUtilCombat.damageIfUnblocked(pCard, opp, null);
computerForces += 1; computerForces += 1;
} }
} }
} }
// find the potential damage ratio the AI can cause // find the potential damage ratio the AI can cause
double humanLifeToDamageRatio = 1000000; double humanLifeToDamageRatio = 1000000;
if (candidateUnblockedDamage > 0) { if (candidateUnblockedDamage > 0) {
humanLifeToDamageRatio = (double) opp.getLife() / candidateUnblockedDamage; humanLifeToDamageRatio = (double) (opp.getLife() - ComputerUtil.possibleNonCombatDamage(ai)) / candidateUnblockedDamage;
} }
// determine if the ai outnumbers the player // determine if the ai outnumbers the player

View File

@@ -1103,10 +1103,47 @@ public class ComputerUtil {
} }
} }
} }
return false; return false;
} // hasACardGivingHaste } // hasACardGivingHaste
/**
* TODO: Write javadoc for this method.
* @param ai
* @return
*/
public static int possibleNonCombatDamage(Player ai) {
int damage = 0;
final List<Card> all = new ArrayList<Card>(ai.getCardsIn(ZoneType.Battlefield));
all.addAll(CardFactoryUtil.getExternalZoneActivationCards(ai));
all.addAll(ai.getCardsIn(ZoneType.Hand));
for (final Card c : all) {
for (final SpellAbility sa : c.getSpellAbilities()) {
if (sa.getApi() != ApiType.DealDamage) {
continue;
}
final String numDam = sa.getParam("NumDmg");
int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), numDam, sa);
if (dmg <= damage) {
continue;
}
final Target tgt = sa.getTarget();
if (tgt == null) {
continue;
}
final Player enemy = ai.getOpponent();
if (!sa.canTarget(enemy)) {
continue;
}
if (!ComputerUtilCost.canPayCost(sa, ai)) {
continue;
}
damage = dmg;
}
}
return damage;
}
/** /**
* <p> * <p>
* predictThreatenedObjects. * predictThreatenedObjects.