mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- More little improvements in AI blocking decisions.
This commit is contained in:
@@ -56,6 +56,7 @@ public class ComputerUtil_Block2
|
|||||||
ArrayList<Object> defenders = combat.getDefenders();
|
ArrayList<Object> defenders = combat.getDefenders();
|
||||||
|
|
||||||
//Begin with the attackers that pose the biggest thread
|
//Begin with the attackers that pose the biggest thread
|
||||||
|
CardListUtil.sortByEvaluateCreature(attackerLists[0]);
|
||||||
CardListUtil.sortAttack(attackerLists[0]);
|
CardListUtil.sortAttack(attackerLists[0]);
|
||||||
|
|
||||||
// If I don't have any planeswalkers than sorting doesn't really matter
|
// If I don't have any planeswalkers than sorting doesn't really matter
|
||||||
@@ -182,6 +183,7 @@ public class ComputerUtil_Block2
|
|||||||
CardList usableBlockers = new CardList();
|
CardList usableBlockers = new CardList();
|
||||||
CardList blockGang = new CardList();
|
CardList blockGang = new CardList();
|
||||||
int absorbedDamage = 0; //The amount of damage needed to kill the first blocker
|
int absorbedDamage = 0; //The amount of damage needed to kill the first blocker
|
||||||
|
int currentValue = 0; //The value of the creatures in the blockgang
|
||||||
|
|
||||||
//Try to add blockers that could be destroyed, but are worth less than the attacker
|
//Try to add blockers that could be destroyed, but are worth less than the attacker
|
||||||
//Don't use blockers without First Strike or Double Strike if attacker has it
|
//Don't use blockers without First Strike or Double Strike if attacker has it
|
||||||
@@ -193,30 +195,32 @@ public class ComputerUtil_Block2
|
|||||||
return CardFactoryUtil.evaluateCreature(c) + diff < CardFactoryUtil.evaluateCreature(attacker);
|
return CardFactoryUtil.evaluateCreature(c) + diff < CardFactoryUtil.evaluateCreature(attacker);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (usableBlockers.size() < 2)
|
||||||
|
return combat;
|
||||||
|
|
||||||
Card leader = CardFactoryUtil.AI_getBestCreature(usableBlockers);
|
Card leader = CardFactoryUtil.AI_getBestCreature(usableBlockers);
|
||||||
if (leader != null)
|
blockGang.add(leader);
|
||||||
{
|
usableBlockers.remove(leader);
|
||||||
blockGang.add(leader);
|
absorbedDamage = leader.getEnoughDamageToKill(attacker.getNetCombatDamage(), attacker, true);
|
||||||
usableBlockers.remove(leader);
|
currentValue = CardFactoryUtil.evaluateCreature(leader);
|
||||||
absorbedDamage = leader.getEnoughDamageToKill(attacker.getNetCombatDamage(), attacker, true);
|
|
||||||
|
|
||||||
for(Card blocker : usableBlockers) {
|
for(Card blocker : usableBlockers) {
|
||||||
//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, blockGang);
|
int currentDamage = CombatUtil.totalDamageOfBlockers(attacker, blockGang);
|
||||||
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);
|
||||||
if(attacker.getKillDamage() > currentDamage
|
int addedValue = CardFactoryUtil.evaluateCreature(blocker);
|
||||||
&& !(attacker.getKillDamage() > currentDamage + additionalDamage)
|
if(attacker.getKillDamage() > currentDamage
|
||||||
&& absorbedDamage2 + absorbedDamage > attacker.getNetCombatDamage()
|
&& !(attacker.getKillDamage() > currentDamage + additionalDamage) //The attacker will be killed
|
||||||
&& CombatUtil.canBlock(attacker,blocker,combat)) {
|
&& (absorbedDamage2 + absorbedDamage > attacker.getNetCombatDamage() //only one blocker can be killed
|
||||||
currentAttackers.remove(attacker);
|
|| currentValue + addedValue - 50 <= CardFactoryUtil.evaluateCreature(attacker)) //attacker is worth than the sum
|
||||||
combat.addBlocker(attacker, blocker);
|
&& CombatUtil.canBlock(attacker,blocker,combat)) {//this is needed for attackers that can't be blocked by more than 1
|
||||||
combat.addBlocker(attacker, leader);
|
currentAttackers.remove(attacker);
|
||||||
blockersLeft.remove(blocker);
|
combat.addBlocker(attacker, blocker);
|
||||||
blockersLeft.remove(leader);
|
combat.addBlocker(attacker, leader);
|
||||||
continue;
|
blockersLeft.remove(blocker);
|
||||||
}
|
blockersLeft.remove(leader);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,7 +374,7 @@ public class ComputerUtil_Block2
|
|||||||
CardList blockers = new CardList();
|
CardList blockers = new CardList();
|
||||||
CardList chumpBlockers = new CardList();
|
CardList chumpBlockers = new CardList();
|
||||||
|
|
||||||
diff = AllZone.ComputerPlayer.getLife() * 2; //This is the minimal gain for an unnecessary trade
|
diff = AllZone.ComputerPlayer.getLife() * 2 - 5; //This is the minimal gain for an unnecessary trade
|
||||||
|
|
||||||
// remove all attackers that can't be blocked anyway
|
// remove all attackers that can't be blocked anyway
|
||||||
for(Card a : attackers) {
|
for(Card a : attackers) {
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ public class CardFactoryUtil {
|
|||||||
public static int evaluateCreature(Card c) {
|
public static int evaluateCreature(Card c) {
|
||||||
|
|
||||||
int value = 100;
|
int value = 100;
|
||||||
|
if (c.isToken()) value = 80; //tokens should be worth less than actual cards
|
||||||
int power = c.getNetAttack();
|
int power = c.getNetAttack();
|
||||||
int toughness = c.getNetDefense();
|
int toughness = c.getNetDefense();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user