- Improved blocking AI predicting multiblocks.

This commit is contained in:
Sloth
2011-08-26 09:00:11 +00:00
parent 157217e7a7
commit 0dc7434844
3 changed files with 17 additions and 13 deletions

View File

@@ -3,7 +3,6 @@ ManaCost:1 W
Types:Instant Arcane Types:Instant Arcane
Text:no text Text:no text
A:SP$ Destroy | Cost$ 1 W | ValidTgts$ Creature.powerLE3+attacking | TgtPrompt$ Select target attacking creature with power 3 or less | SpellDescription$ Destroy target attacking creature with power 3 or less. A:SP$ Destroy | Cost$ 1 W | ValidTgts$ Creature.powerLE3+attacking | TgtPrompt$ Select target attacking creature with power 3 or less | SpellDescription$ Destroy target attacking creature with power 3 or less.
SVar:RemAIDeck:True
SVar:Rarity:Uncommon SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/terashis_verdict.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/terashis_verdict.jpg
SetInfo:BOK|Uncommon|http://magiccards.info/scans/en/bok/27.jpg SetInfo:BOK|Uncommon|http://magiccards.info/scans/en/bok/27.jpg

View File

@@ -875,9 +875,10 @@ public class CombatUtil {
if (attacker.hasKeyword("Indestructible") if (attacker.hasKeyword("Indestructible")
&& !(defender.hasKeyword("Wither") || defender.hasKeyword("Infect"))) return 0; && !(defender.hasKeyword("Wither") || defender.hasKeyword("Infect"))) return 0;
int defBushidoMagnitude = defender.getKeywordMagnitude("Bushido"); int defenderDamage = defender.getNetAttack() + predictPowerBonusOfBlocker(attacker, defender);
if (AllZoneUtil.isCardInPlay("Doran, the Siege Tower")) {
int defenderDamage = defender.getNetCombatDamage() - flankingMagnitude + defBushidoMagnitude; defenderDamage = defender.getNetDefense() + predictToughnessBonusOfBlocker(attacker, defender);
}
// consider static Damage Prevention // consider static Damage Prevention
defenderDamage = attacker.predictDamage(defenderDamage, defender, true); defenderDamage = attacker.predictDamage(defenderDamage, defender, true);

View File

@@ -302,10 +302,11 @@ public class ComputerUtil_Block2 {
if (firstStrikeBlockers.size() > 1) { if (firstStrikeBlockers.size() > 1) {
CardListUtil.sortAttack(firstStrikeBlockers); CardListUtil.sortAttack(firstStrikeBlockers);
for (Card blocker : firstStrikeBlockers) { for (Card blocker : firstStrikeBlockers) {
int damageNeeded = attacker.getKillDamage() + CombatUtil.predictToughnessBonusOfAttacker(attacker, blocker, combat);
//if the total damage of the blockgang was not enough without but is enough with this blocker finish the blockgang //if the total damage of the blockgang was not enough without but is enough with this blocker finish the blockgang
if (CombatUtil.totalDamageOfBlockers(attacker, blockGang) < attacker.getKillDamage()) { if (CombatUtil.totalDamageOfBlockers(attacker, blockGang) < damageNeeded) {
blockGang.add(blocker); blockGang.add(blocker);
if (CombatUtil.totalDamageOfBlockers(attacker, blockGang) >= attacker.getKillDamage()) { if (CombatUtil.totalDamageOfBlockers(attacker, blockGang) >= damageNeeded) {
currentAttackers.remove(attacker); currentAttackers.remove(attacker);
for (Card b : blockGang) { for (Card b : blockGang) {
getBlockersLeft().remove(b); getBlockersLeft().remove(b);
@@ -354,8 +355,9 @@ public class ComputerUtil_Block2 {
int additionalDamage = CombatUtil.dealsDamageAsBlocker(attacker, blocker); int additionalDamage = CombatUtil.dealsDamageAsBlocker(attacker, blocker);
int absorbedDamage2 = blocker.getEnoughDamageToKill(attacker.getNetCombatDamage(), attacker, true); int absorbedDamage2 = blocker.getEnoughDamageToKill(attacker.getNetCombatDamage(), attacker, true);
int addedValue = CardFactoryUtil.evaluateCreature(blocker); int addedValue = CardFactoryUtil.evaluateCreature(blocker);
if (attacker.getKillDamage() > currentDamage int damageNeeded = attacker.getKillDamage() + CombatUtil.predictToughnessBonusOfAttacker(attacker, blocker, combat);
&& !(attacker.getKillDamage() > currentDamage + additionalDamage) //The attacker will be killed if (damageNeeded > currentDamage
&& !(damageNeeded > currentDamage + additionalDamage) //The attacker will be killed
&& (absorbedDamage2 + absorbedDamage > attacker.getNetCombatDamage() //only one blocker can be killed && (absorbedDamage2 + absorbedDamage > attacker.getNetCombatDamage() //only one blocker can be killed
|| currentValue + addedValue - 50 <= CardFactoryUtil.evaluateCreature(attacker)) //attacker is worth more || currentValue + addedValue - 50 <= CardFactoryUtil.evaluateCreature(attacker)) //attacker is worth more
&& CombatUtil.canBlock(attacker, blocker, combat)) {//this is needed for attackers that can't be blocked by more than 1 && CombatUtil.canBlock(attacker, blocker, combat)) {//this is needed for attackers that can't be blocked by more than 1
@@ -480,8 +482,9 @@ public class ComputerUtil_Block2 {
//Try to use safe blockers first //Try to use safe blockers first
safeBlockers = getSafeBlockers(attacker, blockers, combat); safeBlockers = getSafeBlockers(attacker, blockers, combat);
for (Card blocker : safeBlockers) { for (Card blocker : safeBlockers) {
int damageNeeded = attacker.getKillDamage() + CombatUtil.predictToughnessBonusOfAttacker(attacker, blocker, combat);
//Add an additional blocker if the current blockers are not enough and the new one would deal additional damage //Add an additional blocker if the current blockers are not enough and the new one would deal additional damage
if (attacker.getKillDamage() > CombatUtil.totalDamageOfBlockers(attacker, combat.getBlockers(attacker)) if (damageNeeded > CombatUtil.totalDamageOfBlockers(attacker, combat.getBlockers(attacker))
&& CombatUtil.dealsDamageAsBlocker(attacker, blocker) > 0 && CombatUtil.canBlock(attacker, blocker, combat)) { && CombatUtil.dealsDamageAsBlocker(attacker, blocker) > 0 && CombatUtil.canBlock(attacker, blocker, combat)) {
combat.addBlocker(attacker, blocker); combat.addBlocker(attacker, blocker);
getBlockersLeft().remove(blocker); getBlockersLeft().remove(blocker);
@@ -497,11 +500,12 @@ public class ComputerUtil_Block2 {
} else safeBlockers = new CardList(blockers.toArray()); } else safeBlockers = new CardList(blockers.toArray());
for (Card blocker : safeBlockers) { for (Card blocker : safeBlockers) {
int damageNeeded = attacker.getKillDamage() + CombatUtil.predictToughnessBonusOfAttacker(attacker, blocker, combat);
//Add an additional blocker if the current blockers are not enough and the new one would deal the remaining damage //Add an additional blocker if the current blockers are not enough and the new one would deal the remaining damage
int currentDamage = CombatUtil.totalDamageOfBlockers(attacker, combat.getBlockers(attacker)); int currentDamage = CombatUtil.totalDamageOfBlockers(attacker, combat.getBlockers(attacker));
int additionalDamage = CombatUtil.dealsDamageAsBlocker(attacker, blocker); int additionalDamage = CombatUtil.dealsDamageAsBlocker(attacker, blocker);
if (attacker.getKillDamage() > currentDamage if (damageNeeded > currentDamage
&& !(attacker.getKillDamage() > currentDamage + additionalDamage) && !(damageNeeded > currentDamage + additionalDamage)
&& CardFactoryUtil.evaluateCreature(blocker) + getDiff() < CardFactoryUtil.evaluateCreature(attacker) && CardFactoryUtil.evaluateCreature(blocker) + getDiff() < CardFactoryUtil.evaluateCreature(attacker)
&& CombatUtil.canBlock(attacker, blocker, combat)) { && CombatUtil.canBlock(attacker, blocker, combat)) {
combat.addBlocker(attacker, blocker); combat.addBlocker(attacker, blocker);