added HINT:castpriority(blah,blah,blah,blah,ect)
this is a method to set the order in which ai decides to play cards, you can for example tell ai to look for 2 instants, before trying to find a creature.
be sure to list all main types of the deck otherwise ai will pass on stuff
this is the current
const char* types[] = {"planeswalker","creature", "enchantment", "artifact", "sorcery", "instant"};
so be sure you include them if the decks need them.
other the above example would be coded
HINT:castpriority(instant,instant,creature,planeswalker,enchantment,artifact,sorcery)
as you can see this deck will now look for and play if possible, 2 instants before any of the other types.
this will really help with decks which rely on cards like dark ritual to produce mana to cast creature, simply by listing instant before creature. if the deck had dark rituals, in the above example, and it had them in hand, it would then cast dark ritual, dark ritual, then one of the remaining types. this is actually tested not just assumed.
This commit is contained in:
@@ -17,6 +17,7 @@ public:
|
||||
string mCondition;
|
||||
string mAction;
|
||||
string mCombatAttackTip;
|
||||
vector<string>castOrder;
|
||||
int mSourceId;
|
||||
AIHint(string line);
|
||||
};
|
||||
@@ -38,6 +39,7 @@ public:
|
||||
AIHints (AIPlayerBaka * player);
|
||||
AIAction * suggestAbility(ManaCost * potentialMana);
|
||||
bool HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
vector<string> mCastOrder();
|
||||
void add(string line);
|
||||
~AIHints();
|
||||
};
|
||||
|
||||
@@ -37,6 +37,12 @@ AIHint::AIHint(string _line)
|
||||
{
|
||||
mCombatAttackTip = splitDontAttack[1];
|
||||
}
|
||||
|
||||
vector<string> splitCastOrder = parseBetween(action, "castpriority(", ")");
|
||||
if(splitCastOrder.size())
|
||||
{
|
||||
castOrder = split(splitCastOrder[1],',');
|
||||
}
|
||||
}
|
||||
|
||||
AIHints::AIHints(AIPlayerBaka * player): mPlayer(player)
|
||||
@@ -88,6 +94,18 @@ bool AIHints::HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card)
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<string>AIHints::mCastOrder()
|
||||
{
|
||||
for(unsigned int i = 0; i < hints.size();i++)
|
||||
{
|
||||
if (hints[i]->castOrder.size())
|
||||
{
|
||||
return hints[i]->castOrder;
|
||||
}
|
||||
}
|
||||
return vector<string>();
|
||||
}
|
||||
|
||||
//return true if a given ability matches a hint's description
|
||||
//Eventually this will look awfully similar to the parser...any way to merge them somehow ?
|
||||
bool AIHints::abilityMatches(MTGAbility * ability, AIHint * hint)
|
||||
@@ -251,7 +269,7 @@ AIAction * AIHints::findAbilityRecursive(AIHint * hint, ManaCost * potentialMana
|
||||
}
|
||||
|
||||
string s = constraintsNotFulfilled(a, hint, potentialMana);
|
||||
if (hint->mCombatAttackTip.size())
|
||||
if (hint->mCombatAttackTip.size() || hint->castOrder.size())
|
||||
return NULL;
|
||||
if (s.size())
|
||||
{
|
||||
|
||||
@@ -1910,19 +1910,37 @@ int AIPlayerBaka::computeActions()
|
||||
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "land");
|
||||
//look for the most expensive creature we can afford. If not found, try enchantment, then artifact, etc...
|
||||
const char* types[] = {"planeswalker","creature", "enchantment", "artifact", "sorcery", "instant"};
|
||||
int count = 0;
|
||||
while (!nextCardToPlay && count < 6)
|
||||
if(hints && hints->mCastOrder().size())
|
||||
{
|
||||
if(clickstream.size()) //don't find cards while we have clicking to do.
|
||||
vector<string>findType = hints->mCastOrder();
|
||||
for(unsigned int j = 0;j < findType.size();j++)
|
||||
{
|
||||
SAFE_DELETE(currentMana);
|
||||
return 0;
|
||||
if(clickstream.size())
|
||||
{
|
||||
SAFE_DELETE(currentMana);
|
||||
return 0;
|
||||
}
|
||||
nextCardToPlay = FindCardToPlay(currentMana, findType[j].c_str());
|
||||
if (game->playRestrictions->canPutIntoZone(nextCardToPlay, game->stack) == PlayRestriction::CANT_PLAY)
|
||||
nextCardToPlay = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* types[] = {"planeswalker","creature", "enchantment", "artifact", "sorcery", "instant"};
|
||||
int count = 0;
|
||||
while (!nextCardToPlay && count < 6)
|
||||
{
|
||||
if(clickstream.size()) //don't find cards while we have clicking to do.
|
||||
{
|
||||
SAFE_DELETE(currentMana);
|
||||
return 0;
|
||||
}
|
||||
nextCardToPlay = FindCardToPlay(currentMana, types[count]);
|
||||
if (game->playRestrictions->canPutIntoZone(nextCardToPlay, game->stack) == PlayRestriction::CANT_PLAY)
|
||||
nextCardToPlay = NULL;
|
||||
count++;
|
||||
}
|
||||
nextCardToPlay = FindCardToPlay(currentMana, types[count]);
|
||||
if (game->playRestrictions->canPutIntoZone(nextCardToPlay, game->stack) == PlayRestriction::CANT_PLAY)
|
||||
nextCardToPlay = NULL;
|
||||
count++;
|
||||
}
|
||||
|
||||
SAFE_DELETE(currentMana);
|
||||
|
||||
Reference in New Issue
Block a user