AI getAIPlayableMana
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
AI getAIPlayableMana
by friarsol » 13 Apr 2014, 23:40
Soo I'm curious if there's any reason that ComputerUtilMana.getAIPlayableMana(Card) doesn't actually have a call to canPlay() for each ability that it's looking at:
I added a a.canPlay() so he stopped illegally activating Lion's Eye Diamond but I wasn't sure if this would have any long term bad effects.
I added a a.canPlay() so he stopped illegally activating Lion's Eye Diamond but I wasn't sure if this would have any long term bad effects.
- getAIPlayableMana | Open
- public static final ArrayList<SpellAbility> getAIPlayableMana(Card c) {
final ArrayList<SpellAbility> res = new ArrayList<SpellAbility>();
for (final SpellAbility a : c.getManaAbility()) {
// if a mana ability has a mana cost the AI will miscalculate
// if there is a parent ability the AI can't use it
final Cost cost = a.getPayCosts();
if (!cost.hasNoManaCost() || (a.getApi() != ApiType.Mana && a.getApi() != ApiType.ManaReflected ) || a.canPlay()) {
continue;
}
if (!res.contains(a)) {
if (cost.isReusuableResource()) {
res.add(0, a);
} else {
res.add(res.size(), a);
}
}
}
return res;
}
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
!
by Sloth » 14 Apr 2014, 11:00
1. There are canPlay() checks in getAvailableMana and (more importantly) groupSourcesByManaColor.
2. Your code looks like the logic is reversed. Shouldn't it be !a.canPlay()?
EDIT: To fix the problem, maybe another canPlay() check should be placed in payManaCost.
2. Your code looks like the logic is reversed. Shouldn't it be !a.canPlay()?
EDIT: To fix the problem, maybe another canPlay() check should be placed in payManaCost.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: AI getAIPlayableMana
by friarsol » 14 Apr 2014, 12:22
Ah yea. I guess at this point we're not in the middle of paying mana yet, so Instants are still playable? I was just thinking that the AI doesn't have specific checks for not trying to activate RemAIDeck mana abilities and was trying to think of the best way to do it.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 18 guests