AI issues of SpDestroyTgt
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
6 posts
• Page 1 of 1
AI issues of SpDestroyTgt
by Sloth » 03 Aug 2010, 12:37
To determine the best targets, the AI uses this entry:
but if the only possible targets have a form like Creature.nonBlack, they don't get considered and the AI won't find a target (Yes that means the AI is currently not able to use Doom Blade and most of all creature removal spells
)
I fixed this for spBounceTgt by replacing Tgts[i].equals("Artifact") with Tgts[i].startsWith("Artifact"). I would suggest doing the same here.
- Code: Select all
if(choices.size() > 0) {
for(int i = 0; i < Tgts.length; i++) {
if(Tgts[i].equals("Artifact")) {
if(CardFactoryUtil.AI_getBestArtifact(choices) != null) results.add(CardFactoryUtil.AI_getBestArtifact(choices));
} else if(Tgts[i].equals("Creature")) {
if(CardFactoryUtil.AI_getBestCreature(choices) != null) results.add(CardFactoryUtil.AI_getBestCreature(choices));
} else if(Tgts[i].equals("Enchantment")) {
if(CardFactoryUtil.AI_getBestEnchantment(choices, card, true) != null) results.add(CardFactoryUtil.AI_getBestEnchantment(
choices, card, true));
} else if(Tgts[i].equals("Land")) {
if(CardFactoryUtil.AI_getBestLand(choices) != null) results.add(CardFactoryUtil.AI_getBestLand(choices));
} else if(Tgts[i].equals("Permanent")) {
if(CardFactoryUtil.AI_getMostExpensivePermanent(choices, card, true) != null) results.add(CardFactoryUtil.AI_getMostExpensivePermanent(
choices, card, true));
}
}
}
but if the only possible targets have a form like Creature.nonBlack, they don't get considered and the AI won't find a target (Yes that means the AI is currently not able to use Doom Blade and most of all creature removal spells

I fixed this for spBounceTgt by replacing Tgts[i].equals("Artifact") with Tgts[i].startsWith("Artifact"). I would suggest doing the same here.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: AI issues of SpDestroyTgt
by Snacko » 03 Aug 2010, 13:17
Better to use indexOf as it doesn't care where it finds the match as with startsWith. If the substring isn't found -1 is returned.
Re: AI issues of SpDestroyTgt
by Sloth » 03 Aug 2010, 13:52
Well, if the restriction is Creature.Artifact it doesn't have to add all artifact creatures twice though (it would already add everything twice with restrictions like Creature.Artifact,Creature.Black but it doesn't change anything).Snacko wrote:Better to use indexOf as it doesn't care where it finds the match as with startsWith. If the substring isn't found -1 is returned.
Am I forgetting a case where your version is better?
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: AI issues of SpDestroyTgt
by Snacko » 03 Aug 2010, 14:58
Ye in that case it would be better, I didn't check how those type intersections are done in Forge, however still you can't do Creature.Artifact as the code doesn't support it.
Re: AI issues of SpDestroyTgt
by Rob Cashwalker » 03 Aug 2010, 15:20
I recently went through this again in spDiscard. When I started looking at all the "getBest____" routines, the only one that wasn't simply the highest CMC was "getBestCreature" - it uses the p/t.
I think my new approach is more universal.
I think my new approach is more universal.
- Code: Select all
if (dPChHand.size() > 0)
{
CardList dChoices = new CardList();
if (DiscardMethod.contains("Creature") && !DiscardMethod.contains("nonCreature"))
dChoices.add(CardFactoryUtil.AI_getBestCreature(dPChHand));
CardListUtil.sortByTextLen(dPChHand);
dChoices.add(dPChHand.get(0));
CardListUtil.sortCMC(dPChHand);
dChoices.add(dPChHand.get(0));
Card dC = dChoices.get(CardUtil.getRandomIndex(dChoices));
dPChHand.remove(dC);
CardList dCs = new CardList();
dCs.add(dC);
AllZone.Display.getChoiceOptional("Computer has chosen", dCs.toArray());
AllZone.GameAction.discard(dC);
}
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: AI issues of SpDestroyTgt
by Sloth » 03 Aug 2010, 15:38
I will only fix that the AI can cope with more refined target restrictions.
Maybe the AI should prefer to destroy creatures in the future, but I will leave that for now.
Maybe the AI should prefer to destroy creatures in the future, but I will leave that for now.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 27 guests