mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Performance
This commit is contained in:
@@ -633,7 +633,7 @@ public class AiBlockController {
|
|||||||
final Card blocker = ComputerUtilCard.getWorstCreatureAI(killingBlockers);
|
final Card blocker = ComputerUtilCard.getWorstCreatureAI(killingBlockers);
|
||||||
boolean doTrade = false;
|
boolean doTrade = false;
|
||||||
|
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
// Always trade when life in danger
|
// Always trade when life in danger
|
||||||
doTrade = true;
|
doTrade = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -647,7 +647,7 @@ public class AiBlockController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attackersLeft = new ArrayList<>(currentAttackers);
|
attackersLeft = currentAttackers;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chump Blocks (should only be made if life is in danger)
|
// Chump Blocks (should only be made if life is in danger)
|
||||||
@@ -656,13 +656,17 @@ public class AiBlockController {
|
|||||||
|
|
||||||
makeChumpBlocks(combat, currentAttackers);
|
makeChumpBlocks(combat, currentAttackers);
|
||||||
|
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger) {
|
||||||
makeMultiChumpBlocks(combat);
|
makeMultiChumpBlocks(combat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeChumpBlocks(final Combat combat, List<Card> attackers) {
|
private void makeChumpBlocks(final Combat combat, List<Card> attackers) {
|
||||||
if (attackers.isEmpty() || !ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
|
lifeInDanger = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (attackers.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -848,9 +852,8 @@ public class AiBlockController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeChumpBlocksToSavePW(Combat combat) {
|
private void makeChumpBlocksToSavePW(Combat combat) {
|
||||||
if (ai.getLife() <= ai.getStartingLife() / 5 || ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger) {
|
||||||
// most likely not worth trying to protect planeswalkers when at threateningly low life or in
|
// most likely not worth trying to protect planeswalkers when at threateningly low life
|
||||||
// dangerous combat which threatens lethal or severe damage to face
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1078,11 +1081,10 @@ public class AiBlockController {
|
|||||||
makeTradeBlocks(combat); // choose necessary trade blocks
|
makeTradeBlocks(combat); // choose necessary trade blocks
|
||||||
|
|
||||||
// if life is still in danger
|
// if life is still in danger
|
||||||
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger) {
|
||||||
makeChumpBlocks(combat); // choose necessary chump blocks
|
makeChumpBlocks(combat); // choose necessary chump blocks
|
||||||
} else {
|
|
||||||
lifeInDanger = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reinforce blockers blocking attackers with trample if life is still in danger
|
// Reinforce blockers blocking attackers with trample if life is still in danger
|
||||||
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
reinforceBlockersAgainstTrample(combat);
|
reinforceBlockersAgainstTrample(combat);
|
||||||
@@ -1096,25 +1098,23 @@ public class AiBlockController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO could be made more accurate if this would be inside each blocker choosing loop instead
|
// TODO could be made more accurate if this would be inside each blocker choosing loop instead
|
||||||
lifeInDanger |= removeUnpayableBlocks(combat);
|
lifeInDanger |= removeUnpayableBlocks(combat) && ComputerUtilCombat.lifeInDanger(ai, 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 (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger) {
|
||||||
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
|
||||||
makeGoodBlocks(combat);
|
makeGoodBlocks(combat);
|
||||||
// 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)) {
|
|
||||||
makeChumpBlocks(combat);
|
makeChumpBlocks(combat);
|
||||||
} else {
|
|
||||||
lifeInDanger = false;
|
|
||||||
}
|
|
||||||
// Reinforce blockers blocking attackers with trample if life is still in danger
|
// Reinforce blockers blocking attackers with trample if life is still in danger
|
||||||
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
reinforceBlockersAgainstTrample(combat);
|
reinforceBlockersAgainstTrample(combat);
|
||||||
} else {
|
} else {
|
||||||
lifeInDanger = false;
|
lifeInDanger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeGangBlocks(combat);
|
makeGangBlocks(combat);
|
||||||
reinforceBlockersToKill(combat);
|
reinforceBlockersToKill(combat);
|
||||||
}
|
}
|
||||||
@@ -1123,15 +1123,23 @@ public class AiBlockController {
|
|||||||
if (lifeInDanger && ComputerUtilCombat.lifeInSeriousDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInSeriousDanger(ai, combat)) {
|
||||||
clearBlockers(combat, possibleBlockers);
|
clearBlockers(combat, possibleBlockers);
|
||||||
makeChumpBlocks(combat);
|
makeChumpBlocks(combat);
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
|
||||||
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
makeTradeBlocks(combat);
|
makeTradeBlocks(combat);
|
||||||
|
} else {
|
||||||
|
lifeInDanger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
makeGoodBlocks(combat);
|
|
||||||
} else {
|
|
||||||
reinforceBlockersAgainstTrample(combat);
|
reinforceBlockersAgainstTrample(combat);
|
||||||
|
} else {
|
||||||
|
lifeInDanger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!lifeInDanger) {
|
||||||
|
makeGoodBlocks(combat);
|
||||||
|
}
|
||||||
|
|
||||||
makeGangBlocks(combat);
|
makeGangBlocks(combat);
|
||||||
reinforceBlockersToKill(combat);
|
reinforceBlockersToKill(combat);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user