Crib Swap AI
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
2 posts
• Page 1 of 1
Crib Swap AI
by Chris H. » 23 Jul 2010, 15:04
Ran a few tests and I discovered that the AI will attempt to target creatures with Protection from black. Ugh. This is an easy one to fix.
With more testing I was able to reproduce the problem that the OP found. And in one test I saw that I was able to enchant a "Shapeshifter" token to an incredible size and the AI failed to use a Crib Swap to make the auras "fall off".
I looked at the Pongify spell and I am considering something similar. I think that we should filter on the power being >= 3 rather than on the name.
With more testing I was able to reproduce the problem that the OP found. And in one test I saw that I was able to enchant a "Shapeshifter" token to an incredible size and the AI failed to use a Crib Swap to make the auras "fall off".
I looked at the Pongify spell and I am considering something similar. I think that we should filter on the power being >= 3 rather than on the name.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Crib Swap AI
by Chris H. » 24 Jul 2010, 00:34
I improved the AI for Crib Swap. The AI will now only target creatures with a net attack > 2. The AI will not include creatures named "Shapeshifter" unless the card has an aura and/or a P1P1 counter buff.
This will allow the AI to remove these types of buffs. Other types of buffs are not included, as there may be Lord like permanents in play granting the buffs.
This will allow the AI to remove these types of buffs. Other types of buffs are not included, as there may be Lord like permanents in play granting the buffs.
- Code: Select all
//*************** START *********** START **************************
else if(cardName.equals("Crib Swap")) {
SpellAbility spell = new Spell(card) {
private static final long serialVersionUID = -4567382566960071562L;
@Override
public void resolve() {
if(AllZone.GameAction.isCardInPlay(getTargetCard())
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
String controller = getTargetCard().getController();
AllZone.GameAction.removeFromGame(getTargetCard());
CardFactoryUtil.makeToken("Shapeshifter", "C 1 1 Shapeshifter",
controller, "", new String[] {"Creature", "Shapeshifter"}, 1,
1, new String[] {"Changeling"});
}
}//resolve()
@Override
public boolean canPlayAI() {
return (getCreature().size() != 0) && (AllZone.Phase.getTurn() > 4);
}//canPlayAI()
CardList getCreature() {
CardList list = CardFactoryUtil.AI_getHumanCreature(card, true);
list = list.filter(new CardListFilter() {
public boolean addCard(Card c) {
return (c.getNetAttack() > 2
&& CardFactoryUtil.canTarget(card, c)
&& (!c.getName().equals("Shapeshifter")
|| (c.getName().equals("Shapeshifter")
&& (c.isEnchanted()
|| c.getCounters(Counters.P1P1) != 0))));
}
});
return list;
}//getCreature()
@Override
public void chooseTargetAI() {
Card best = CardFactoryUtil.AI_getBestCreature(getCreature());
setTargetCard(best);
}//chooseTargetAI()
};//SpellAbility
spell.setBeforePayMana(CardFactoryUtil.input_targetCreature(spell));
card.setSVar("PlayMain1", "TRUE");
card.clearSpellAbility();
card.addSpellAbility(spell);
}//*************** END ************ END **************************
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 39 guests