It is currently 24 Apr 2024, 11:22
   
Text Size

AI getAIPlayableMana

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

AI getAIPlayableMana

Postby 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.

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

!

Postby 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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: AI getAIPlayableMana

Postby 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


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 37 guests


Who is online

In total there are 37 users online :: 0 registered, 0 hidden and 37 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 37 guests

Login Form