Better Ai: Foreach training, reduced Eff on "levelingup" based on cards in hand/maxxed in 2nd main, added a selectAbility() call after lands are played and after all cards were searched if none were found to play. after much playtesting i found that if given the chance to find an ability BEFORE playing cards, Ai does dramatically better during a match, the same goes if its given a chance to find one after it looked for stuff to play.
with this change please try playing a few matchs against vanguards chosen and wraith feast, my 2 most favorate decks to fight now. youre in for a treat :) keep in mind that even tho ive taught Ai Foreach in a somewhat crude manner it still does not understand how much mana it can gain from a foreach manaproducer, and this does not make it suddenly use dark ritual correctly. however this change was dramatic enough that i wanted it in for 14.1 this is also still under massive play testing, however no issues were found so far with it as it is presented here.
This commit is contained in:
@@ -45,8 +45,10 @@ public:
|
||||
class CmpAbilities { // compares Abilities efficiency
|
||||
public:
|
||||
bool operator()(AIAction * a1, AIAction * a2) const {
|
||||
int e1 = a1->getEfficiency();
|
||||
int e2 = a2->getEfficiency();
|
||||
int e1 = 0;
|
||||
e1 = a1->getEfficiency();
|
||||
int e2 = 0;
|
||||
e2 = a2->getEfficiency();
|
||||
if (e1 == e2) return a1->id < a2->id;
|
||||
return (e1 > e2);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ class MTGGameZone {
|
||||
MTGCardInstance * findByName(string name);
|
||||
int hasAbility(int ability); //returns 1 if one of the cards in the zone has the ability, 0 otherwise
|
||||
int hasType(const char * value); //returns 1 if one of the cards in the zone has the type, 0 otherwise
|
||||
int hasColor(int value); //returns 1 if one of the cards in the zone has the color, 0 otherwise
|
||||
int hasX();
|
||||
void setOwner(Player * player);
|
||||
MTGCardInstance * lastCardDrawn;
|
||||
static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target);
|
||||
|
||||
@@ -322,6 +322,16 @@ int AIAction::getEfficiency()
|
||||
//increase the efficeincy of leveling up by a small amount equal to current level.
|
||||
efficiency += currentlevel;
|
||||
}
|
||||
if(p->game->hand->nb_cards > 0 && p->isAI())
|
||||
{
|
||||
efficiency -= (10 * p->game->hand->nb_cards);//reduce the eff if by 10 times the amount of cards in Ais hand.
|
||||
//it should always try playing more cards before deciding
|
||||
}
|
||||
if(g->getCurrentGamePhase() == Constants::MTG_PHASE_SECONDMAIN)
|
||||
{
|
||||
efficiency = 100;
|
||||
//in 2nd main, go all out and try to max stuff.
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MTGAbility::STANDARD_PUMP:
|
||||
@@ -370,20 +380,49 @@ int AIAction::getEfficiency()
|
||||
case MTGAbility::FOREACH:
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) (a->target);
|
||||
MTGAbility * a = AbilityFactory::getCoreAbility(ability);
|
||||
AManaProducer * amp = dynamic_cast<AManaProducer*> (a);
|
||||
//trying to encourage Ai to use his foreach manaproducers in first main
|
||||
if ((g->getCurrentGamePhase() == Constants::MTG_PHASE_FIRSTMAIN || g->getCurrentGamePhase() == Constants::MTG_PHASE_SECONDMAIN ) && _target->controller()->game->hand->nb_cards > 0)
|
||||
if (a->naType == MTGAbility::MANA_PRODUCER && (g->getCurrentGamePhase() == Constants::MTG_PHASE_FIRSTMAIN || g->getCurrentGamePhase() == Constants::MTG_PHASE_SECONDMAIN )
|
||||
&& _target->controller()->game->hand->nb_cards > 0)
|
||||
{
|
||||
efficiency = 100;
|
||||
}
|
||||
for (int i = Constants::MTG_NB_COLORS - 1; i > 0; i--)
|
||||
{
|
||||
if((p->game->hand->hasColor(i) || p->game->hand->hasColor(0) )
|
||||
&& (dynamic_cast<AManaProducer*>(( dynamic_cast<AForeach*>( a )->ability))->output->hasColor(i)))
|
||||
{
|
||||
efficiency = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
efficiency = 0;
|
||||
}
|
||||
}
|
||||
if(p->game->hand->hasX())
|
||||
{
|
||||
efficiency = 100;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AbilityFactory af;
|
||||
int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY);
|
||||
if (target)
|
||||
{
|
||||
if ((suggestion == BAKA_EFFECT_BAD && p == target->controller()) || (suggestion == BAKA_EFFECT_GOOD && p
|
||||
!= target->controller()))
|
||||
if (a->naType != MTGAbility::MANA_PRODUCER && ((suggestion == BAKA_EFFECT_BAD && p == target->controller()) || (suggestion == BAKA_EFFECT_GOOD && p
|
||||
!= target->controller())))
|
||||
{
|
||||
efficiency = 0;
|
||||
}
|
||||
else if (a->naType != MTGAbility::MANA_PRODUCER)
|
||||
{
|
||||
efficiency = 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
efficiency = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1038,8 +1077,8 @@ int AIPlayerBaka::computeActions()
|
||||
currentMana = getPotentialMana();
|
||||
potential = true;
|
||||
}
|
||||
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "land");
|
||||
selectAbility();
|
||||
//look for the most expensive creature we can afford
|
||||
if (castrestrictedspell == 0 && nospellinstant == 0)
|
||||
{
|
||||
@@ -1071,9 +1110,14 @@ int AIPlayerBaka::computeActions()
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
selectAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (potential)
|
||||
delete (currentMana);
|
||||
if (nextCardToPlay)
|
||||
|
||||
@@ -538,6 +538,30 @@ int MTGGameZone::hasType(const char * value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MTGGameZone::hasColor(int value)
|
||||
{
|
||||
for (int i = 0; i < (nb_cards); i++)
|
||||
{
|
||||
if (cards[i]->getManaCost()->hasColor(value))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MTGGameZone::hasX()
|
||||
{
|
||||
for (int i = 0; i < (nb_cards); i++)
|
||||
{
|
||||
if (cards[i]->getManaCost()->hasX())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int MTGGameZone::hasAbility(int ability)
|
||||
{
|
||||
for (int i = 0; i < (nb_cards); i++)
|
||||
|
||||
Reference in New Issue
Block a user