more Ai training: use ability modifiers on creatures that dont already have the ability and prefferedly during first mains, use life altering cards as often as possible, improved foreach a little more, use untappers on card that are tapped that belong to Ai and tappers on cards that are not tapped that belong to player

This commit is contained in:
omegablast2002@yahoo.com
2010-11-27 18:05:35 +00:00
parent 76dc9a2379
commit e23e3d0728
5 changed files with 85 additions and 10 deletions
+68 -7
View File
@@ -150,7 +150,8 @@ ManaCost * AIPlayer::getPotentialMana(MTGCardInstance * target)
used[card] = true;
}
}
}
}
result->add(this->getManaPool());
return result;
}
@@ -382,21 +383,18 @@ int AIAction::getEfficiency()
MTGCardInstance * _target = (MTGCardInstance *) (a->target);
MTGAbility * a = AbilityFactory::getCoreAbility(ability);
AManaProducer * amp = dynamic_cast<AManaProducer*> (a);
efficiency = 0;
//trying to encourage Ai to use his foreach manaproducers in first main
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)
{
for (int i = Constants::MTG_NB_COLORS - 1; i > 0; i--)
{
if((p->game->hand->hasColor(i) || p->game->hand->hasColor(0) )
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())
{
@@ -426,7 +424,70 @@ int AIAction::getEfficiency()
}
break;
}
case MTGAbility::MANA_PRODUCER: //can't use mana producers right now :/
case MTGAbility::STANDARDABILITYGRANT:
{
efficiency = 0;
MTGCardInstance * _target = (MTGCardInstance *) (a->target);
//ensuring that Ai grants abilities to creatures during first main, so it can actually use them in combat.
if (_target && !_target->has(a->abilitygranted) && g->getCurrentGamePhase() == Constants::MTG_PHASE_FIRSTMAIN)
{
//trying to avoid Ai giving ie:flying creatures ie:flying twice.
efficiency = (20 * _target->DangerRanking());
}
if (target)
{
AbilityFactory af;
int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY);
if ((suggestion == BAKA_EFFECT_BAD && p == target->controller()) || (suggestion == BAKA_EFFECT_GOOD && p
!= target->controller()))
{
efficiency = 0;
//stop giving trample to the players creatures.
}
if (suggestion == BAKA_EFFECT_BAD && p != target->controller() && target->has(a->abilitygranted))
{
efficiency = (20 * _target->DangerRanking());
}
}
break;
}
case MTGAbility::UNTAPPER:
//untap things that Ai owns and are tapped.
{
efficiency = 0;
MTGCardInstance * _target = (MTGCardInstance *) (a->target);
if (_target && _target->isTapped() && p->isAI() && p == _target->controller())
{
efficiency = 100;
}
break;
}
case MTGAbility::TAPPER:
//tap things the player owns and that are untapped.
{
efficiency = 0;
MTGCardInstance * _target = (MTGCardInstance *) (a->target);
if (_target && !_target->isTapped() && p != _target->controller())
{
efficiency = 100;
}
break;
}
case MTGAbility::LIFER:
{
//use life abilities whenever possible.
efficiency = 100;
AbilityFactory af;
int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY);
if ((suggestion == BAKA_EFFECT_BAD && p == a->target) || (suggestion == BAKA_EFFECT_GOOD && p
!= a->target))
{
efficiency = 0;
}
break;
}
case MTGAbility::MANA_PRODUCER:
efficiency = 0;
break;
default:
+3
View File
@@ -550,6 +550,7 @@ AAFrozen * AAFrozen::clone() const
AALifer::AALifer(int _id, MTGCardInstance * card, Targetable * _target, WParsedInt * life, ManaCost * _cost, int _tap, int who) :
ActivatedAbilityTP(_id, card, _target, _cost, _tap, who), life(life)
{
aType = MTGAbility::LIFER;
}
int AALifer::resolve()
@@ -990,6 +991,7 @@ AATapper::AATapper(int id, MTGCardInstance * card, MTGCardInstance * _target, Ma
ActivatedAbility(id, card, _cost, 0, doTap)
{
target = _target;
aType = MTGAbility::TAPPER;
}
int AATapper::resolve()
@@ -1021,6 +1023,7 @@ AAUntapper::AAUntapper(int id, MTGCardInstance * card, MTGCardInstance * _target
ActivatedAbility(id, card, _cost, 0, doTap)
{
target = _target;
aType = MTGAbility::UNTAPPER;
}
int AAUntapper::resolve()
+1 -1
View File
@@ -542,7 +542,7 @@ int MTGGameZone::hasColor(int value)
{
for (int i = 0; i < (nb_cards); i++)
{
if (cards[i]->getManaCost()->hasColor(value))
if (cards[i]->getManaCost()->hasColor(value) && cards[i]->getManaCost()->getConvertedCost() > 0)
{
return 1;
}