- Improved the Attack AI deciding to assault (especially with poison involved).

This commit is contained in:
Sloth
2011-11-05 14:31:31 +00:00
parent cc2ea3cd3f
commit a24dc019b3
2 changed files with 17 additions and 8 deletions

View File

@@ -868,7 +868,7 @@ public class CombatUtil {
* a {@link forge.Player} object. * a {@link forge.Player} object.
* @return a int. * @return a int.
*/ */
private static int sumDamageIfUnblocked(final CardList attackers, final Player attacked) { public static int sumDamageIfUnblocked(final CardList attackers, final Player attacked) {
int sum = 0; int sum = 0;
for (Card attacker : attackers) { for (Card attacker : attackers) {
sum += damageIfUnblocked(attacker, attacked, null); sum += damageIfUnblocked(attacker, attacked, null);
@@ -888,7 +888,7 @@ public class CombatUtil {
* a {@link forge.Player} object. * a {@link forge.Player} object.
* @return a int. * @return a int.
*/ */
private static int sumPoisonIfUnblocked(final CardList attackers, final Player attacked) { public static int sumPoisonIfUnblocked(final CardList attackers, final Player attacked) {
int sum = 0; int sum = 0;
for (Card attacker : attackers) { for (Card attacker : attackers) {
sum += poisonIfUnblocked(attacker, attacked, null); sum += poisonIfUnblocked(attacker, attacked, null);

View File

@@ -330,15 +330,24 @@ public class ComputerUtilAttack {
} }
// I think this is right but the assault code may still be a little off // I think this is right but the assault code may still be a little off
CardListUtil.sortAttackLowFirst(attackers); CardListUtil.sortAttack(attackers);
int totalAttack = 0; CardList remainingAttackers = new CardList(attackers.toArray());
// presumes the Human will block // presumes the Human will block
for (int i = 0; i < (attackers.size() - blockers.size()); i++) { for (int i = 0; i < blockers.size(); i++) {
totalAttack += getAttack(attackers.get(i)); remainingAttackers.remove(attackers.get(i));
} }
return blockerLife <= totalAttack; if(CombatUtil.sumDamageIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) > AllZone.getHumanPlayer().getLife()
&& AllZone.getHumanPlayer().canLoseLife()) {
return true;
}
if(CombatUtil.sumPoisonIfUnblocked(remainingAttackers, AllZone.getHumanPlayer()) >= 10 - AllZone.getHumanPlayer().getPoisonCounters()) {
return true;
}
return false;
} // doAssault() } // doAssault()
/** /**