Page 1 of 1

AI getAIPlayableMana

PostPosted: 13 Apr 2014, 23:40
by friarsol
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.

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;
}

!

PostPosted: 14 Apr 2014, 11:00
by Sloth
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.

Re: AI getAIPlayableMana

PostPosted: 14 Apr 2014, 12:22
by friarsol
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.