mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Improvements in AiBlockController.
This commit is contained in:
@@ -622,6 +622,7 @@ public class AiBlockController {
|
|||||||
blockers.removeAll(combat.getBlockers(attacker));
|
blockers.removeAll(combat.getBlockers(attacker));
|
||||||
|
|
||||||
// Try to use safe blockers first
|
// Try to use safe blockers first
|
||||||
|
if (blockers.size() > 1) {
|
||||||
safeBlockers = getSafeBlockers(combat, attacker, blockers);
|
safeBlockers = getSafeBlockers(combat, attacker, blockers);
|
||||||
for (final Card blocker : safeBlockers) {
|
for (final Card blocker : safeBlockers) {
|
||||||
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
|
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
|
||||||
@@ -635,6 +636,7 @@ public class AiBlockController {
|
|||||||
}
|
}
|
||||||
blockers.remove(blocker); // Don't check them again next
|
blockers.remove(blocker); // Don't check them again next
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@@ -755,28 +757,32 @@ public class AiBlockController {
|
|||||||
|
|
||||||
// When the AI holds some Fog effect, don't bother about lifeInDanger
|
// When the AI holds some Fog effect, don't bother about lifeInDanger
|
||||||
if (!ComputerUtil.hasAFogEffect(ai)) {
|
if (!ComputerUtil.hasAFogEffect(ai)) {
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
lifeInDanger = ComputerUtilCombat.lifeInDanger(ai, combat);
|
||||||
|
if (lifeInDanger) {
|
||||||
makeTradeBlocks(combat); // choose necessary trade blocks
|
makeTradeBlocks(combat); // choose necessary trade blocks
|
||||||
}
|
}
|
||||||
// if life is in danger
|
// if life is still in danger
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
makeChumpBlocks(combat); // choose necessary chump blocks
|
makeChumpBlocks(combat); // choose necessary chump blocks
|
||||||
|
} else {
|
||||||
|
lifeInDanger = false;
|
||||||
}
|
}
|
||||||
// if life is still in danger
|
// if life is still in danger
|
||||||
// Reinforce blockers blocking attackers with trample if life is still
|
// Reinforce blockers blocking attackers with trample if life is still
|
||||||
// in danger
|
// in danger
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
reinforceBlockersAgainstTrample(combat);
|
reinforceBlockersAgainstTrample(combat);
|
||||||
|
} else {
|
||||||
|
lifeInDanger = false;
|
||||||
}
|
}
|
||||||
// Support blockers not destroying the attacker with more blockers to
|
// Support blockers not destroying the attacker with more blockers to
|
||||||
// try to kill the attacker
|
// try to kill the attacker
|
||||||
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (!lifeInDanger) {
|
||||||
reinforceBlockersToKill(combat);
|
reinforceBlockersToKill(combat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// == 2. If the AI life would still be in danger make a safer approach ==
|
// == 2. If the AI life would still be in danger make a safer approach ==
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
lifeInDanger = true;
|
|
||||||
clearBlockers(combat, possibleBlockers); // reset every block assignment
|
clearBlockers(combat, possibleBlockers); // reset every block assignment
|
||||||
makeTradeBlocks(combat); // choose necessary trade blocks
|
makeTradeBlocks(combat); // choose necessary trade blocks
|
||||||
// if life is in danger
|
// if life is in danger
|
||||||
@@ -784,11 +790,15 @@ public class AiBlockController {
|
|||||||
// choose necessary chump blocks if life is still in danger
|
// choose necessary chump blocks if life is still in danger
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
makeChumpBlocks(combat);
|
makeChumpBlocks(combat);
|
||||||
|
} else {
|
||||||
|
lifeInDanger = false;
|
||||||
}
|
}
|
||||||
// Reinforce blockers blocking attackers with trample if life is
|
// Reinforce blockers blocking attackers with trample if life is
|
||||||
// still in danger
|
// still in danger
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
reinforceBlockersAgainstTrample(combat);
|
reinforceBlockersAgainstTrample(combat);
|
||||||
|
} else {
|
||||||
|
lifeInDanger = false;
|
||||||
}
|
}
|
||||||
makeGangBlocks(combat);
|
makeGangBlocks(combat);
|
||||||
reinforceBlockersToKill(combat);
|
reinforceBlockersToKill(combat);
|
||||||
|
|||||||
Reference in New Issue
Block a user