- AI will now try to chump block with creatures that have SacMe SVars > 3 (for example Rukh Egg).

This commit is contained in:
Sloth
2014-04-05 06:12:34 +00:00
parent a71f9c46eb
commit 96338eb652
3 changed files with 20 additions and 19 deletions

View File

@@ -198,7 +198,7 @@ public class AiBlockController {
final List<Card> safeBlockers = getSafeBlockers(combat, attacker, blockers); final List<Card> safeBlockers = getSafeBlockers(combat, attacker, blockers);
List<Card> killingBlockers; List<Card> killingBlockers;
if (safeBlockers.size() > 0) { if (!safeBlockers.isEmpty()) {
// 1.Blockers that can destroy the attacker but won't get // 1.Blockers that can destroy the attacker but won't get
// destroyed // destroyed
killingBlockers = getKillingBlockers(combat, attacker, safeBlockers); killingBlockers = getKillingBlockers(combat, attacker, safeBlockers);
@@ -213,13 +213,19 @@ public class AiBlockController {
// 3.Blockers that can destroy the attacker and have an upside when dying // 3.Blockers that can destroy the attacker and have an upside when dying
killingBlockers = getKillingBlockers(combat, attacker, blockers); killingBlockers = getKillingBlockers(combat, attacker, blockers);
for (Card b : killingBlockers) { for (Card b : killingBlockers) {
if ((b.hasKeyword("Undying") && b.getCounters(CounterType.P1P1) == 0) if ((b.hasKeyword("Undying") && b.getCounters(CounterType.P1P1) == 0) || b.hasSVar("SacMe")) {
|| !b.getSVar("SacMe").equals("")) {
blocker = b; blocker = b;
break; break;
} }
} }
// 4.Blockers that can destroy the attacker and are worth less // 4.Blockers that have a big upside when dying
for (Card b : blockers) {
if (b.hasSVar("SacMe") && Integer.parseInt(b.getSVar("SacMe")) > 3) {
blocker = b;
break;
}
}
// 5.Blockers that can destroy the attacker and are worth less
if (blocker == null && !killingBlockers.isEmpty()) { if (blocker == null && !killingBlockers.isEmpty()) {
final Card worst = ComputerUtilCard.getWorstCreatureAI(killingBlockers); final Card worst = ComputerUtilCard.getWorstCreatureAI(killingBlockers);
int value = ComputerUtilCard.evaluateCreature(attacker); int value = ComputerUtilCard.evaluateCreature(attacker);

View File

@@ -1,5 +1,6 @@
package forge.ai.ability; package forge.ai.ability;
import forge.ai.ComputerUtil;
import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCard;
import forge.ai.ComputerUtilCost; import forge.ai.ComputerUtilCost;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
@@ -12,11 +13,9 @@ import forge.game.player.Player;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions; import forge.game.spellability.TargetRestrictions;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import forge.util.MyRandom;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Random;
public class UntapAi extends SpellAbilityAi { public class UntapAi extends SpellAbilityAi {
@@ -37,8 +36,9 @@ public class UntapAi extends SpellAbilityAi {
return false; return false;
} }
final Random r = MyRandom.getRandom(); if (ComputerUtil.preventRunAwayActivations(sa)) {
boolean randomReturn = r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn() + 1); return false;
}
if (tgt == null) { if (tgt == null) {
final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa); final List<Card> pDefined = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
@@ -51,7 +51,7 @@ public class UntapAi extends SpellAbilityAi {
} }
} }
return randomReturn; return true;
} }
@Override @Override
@@ -133,14 +133,14 @@ public class UntapAi extends SpellAbilityAi {
final String[] tappablePermanents = { "Creature", "Land", "Artifact" }; final String[] tappablePermanents = { "Creature", "Land", "Artifact" };
untapList = CardLists.getValidCards(untapList, tappablePermanents, source.getController(), source); untapList = CardLists.getValidCards(untapList, tappablePermanents, source.getController(), source);
if (untapList.size() == 0) { if (untapList.isEmpty()) {
return false; return false;
} }
while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) { while (sa.getTargets().getNumTargeted() < tgt.getMaxTargets(sa.getHostCard(), sa)) {
Card choice = null; Card choice = null;
if (untapList.size() == 0) { if (untapList.isEmpty()) {
if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) { if ((sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) || (sa.getTargets().getNumTargeted() == 0)) {
sa.resetTargets(); sa.resetTargets();
return false; return false;
@@ -150,13 +150,8 @@ public class UntapAi extends SpellAbilityAi {
} }
} }
if (CardLists.getNotType(untapList, "Creature").size() == 0) { if (CardLists.getNotType(untapList, "Creature").isEmpty()) {
choice = ComputerUtilCard.getBestCreatureAI(untapList); // if choice = ComputerUtilCard.getBestCreatureAI(untapList); // if only creatures take the best
// only
// creatures
// take
// the
// best
} else { } else {
choice = ComputerUtilCard.getMostExpensivePermanentAI(untapList, sa, false); choice = ComputerUtilCard.getMostExpensivePermanentAI(untapList, sa, false);
} }

View File

@@ -4,6 +4,6 @@ Types:Creature Zombie
PT:4/4 PT:4/4
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigToken | TriggerController$ TriggeredCardController | TriggerDescription$ When CARDNAME dies, put two 2/2 black Zombie creature tokens onto the battlefield. T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigToken | TriggerController$ TriggeredCardController | TriggerDescription$ When CARDNAME dies, put two 2/2 black Zombie creature tokens onto the battlefield.
SVar:TrigToken:AB$ Token | Cost$ 0 | TokenImage$ B 2 2 Zombie | TokenAmount$ 2 | TokenName$ Zombie | TokenTypes$ Creature,Zombie | TokenOwner$ You | TokenPower$ 2 | TokenToughness$ 2 | TokenColors$ Black SVar:TrigToken:AB$ Token | Cost$ 0 | TokenImage$ B 2 2 Zombie | TokenAmount$ 2 | TokenName$ Zombie | TokenTypes$ Creature,Zombie | TokenOwner$ You | TokenPower$ 2 | TokenToughness$ 2 | TokenColors$ Black
SVar:SacMe:4 SVar:SacMe:3
SVar:Picture:http://www.wizards.com/global/images/magic/general/maalfeld_twins.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/maalfeld_twins.jpg
Oracle:When Maalfeld Twins dies, put two 2/2 black Zombie creature tokens onto the battlefield. Oracle:When Maalfeld Twins dies, put two 2/2 black Zombie creature tokens onto the battlefield.