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
+8 -2
View File
@@ -1191,7 +1191,8 @@ public:
ABasicAbilityModifier(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int _modifier = 1) : ABasicAbilityModifier(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int _modifier = 1) :
MTGAbility(_id, _source, _target), modifier(_modifier), ability(_ability) MTGAbility(_id, _source, _target), modifier(_modifier), ability(_ability)
{ {
aType = MTGAbility::STANDARDABILITYGRANT;
abilitygranted = ability;
} }
int addToGame() int addToGame()
@@ -1249,6 +1250,8 @@ public:
int _modifier = 1, int _tap = 1) : int _modifier = 1, int _tap = 1) :
TargetAbility(_id, _source, _cost, 0, _tap), modifier(_modifier), ability(_ability) TargetAbility(_id, _source, _cost, 0, _tap), modifier(_modifier), ability(_ability)
{ {
aType = MTGAbility::STANDARDABILITYGRANT;
abilitygranted = ability;
nbTargets = 0; nbTargets = 0;
tc = _tc; tc = _tc;
if (!tc) tc = NEW CreatureTargetChooser(_source); if (!tc) tc = NEW CreatureTargetChooser(_source);
@@ -1321,7 +1324,8 @@ public:
AInstantBasicAbilityModifierUntilEOT(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int value) : AInstantBasicAbilityModifierUntilEOT(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int value) :
InstantAbility(_id, _source, _target), ability(_ability), value(value) InstantAbility(_id, _source, _target), ability(_ability), value(value)
{ {
aType = MTGAbility::STANDARDABILITYGRANT;
abilitygranted = ability;
} }
int addToGame() int addToGame()
@@ -1370,6 +1374,7 @@ public:
{ {
target = _target; target = _target;
ability = NEW AInstantBasicAbilityModifierUntilEOT(_id, _source, _target, _ability, _value); ability = NEW AInstantBasicAbilityModifierUntilEOT(_id, _source, _target, _ability, _value);
aType = MTGAbility::STANDARDABILITYGRANT;
} }
int isReactingToClick(MTGCardInstance * card, ManaCost * cost = NULL) int isReactingToClick(MTGCardInstance * card, ManaCost * cost = NULL)
@@ -1423,6 +1428,7 @@ public:
ASpellCastLife(int id, MTGCardInstance * _source, CardDescriptor _trigger, ManaCost * _cost, int _life) : ASpellCastLife(int id, MTGCardInstance * _source, CardDescriptor _trigger, ManaCost * _cost, int _life) :
MTGAbility(id, _source), trigger(_trigger), cost(_cost), life(_life), lastUsedOn(NULL), lastChecked(NULL) MTGAbility(id, _source), trigger(_trigger), cost(_cost), life(_life), lastUsedOn(NULL), lastChecked(NULL)
{ {
aType = MTGAbility::LIFER;
} }
ASpellCastLife(int id, MTGCardInstance * _source, int color, ManaCost * _cost, int _life) : ASpellCastLife(int id, MTGCardInstance * _source, int color, ManaCost * _cost, int _life) :
MTGAbility(id, _source), cost(_cost), life(_life), lastUsedOn(NULL), lastChecked(NULL) MTGAbility(id, _source), cost(_cost), life(_life), lastUsedOn(NULL), lastChecked(NULL)
+5
View File
@@ -57,6 +57,7 @@ class MTGAbility: public ActionElement{
Targetable * target; Targetable * target;
int aType; int aType;
int naType; int naType;
int abilitygranted;
int nbcardAmount; int nbcardAmount;
MTGCardInstance * source; MTGCardInstance * source;
MTGAbility(int id, MTGCardInstance * card); MTGAbility(int id, MTGCardInstance * card);
@@ -100,6 +101,10 @@ class MTGAbility: public ActionElement{
STANDARD_PUMP = 18, STANDARD_PUMP = 18,
STANDARD_BECOMES = 19, STANDARD_BECOMES = 19,
UPCOST = 20, UPCOST = 20,
STANDARDABILITYGRANT = 21,
UNTAPPER = 22,
TAPPER = 23,
LIFER = 24,
}; };
+66 -5
View File
@@ -151,6 +151,7 @@ ManaCost * AIPlayer::getPotentialMana(MTGCardInstance * target)
} }
} }
} }
result->add(this->getManaPool());
return result; return result;
} }
@@ -382,6 +383,7 @@ int AIAction::getEfficiency()
MTGCardInstance * _target = (MTGCardInstance *) (a->target); MTGCardInstance * _target = (MTGCardInstance *) (a->target);
MTGAbility * a = AbilityFactory::getCoreAbility(ability); MTGAbility * a = AbilityFactory::getCoreAbility(ability);
AManaProducer * amp = dynamic_cast<AManaProducer*> (a); AManaProducer * amp = dynamic_cast<AManaProducer*> (a);
efficiency = 0;
//trying to encourage Ai to use his foreach manaproducers in first main //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 ) 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) && _target->controller()->game->hand->nb_cards > 0)
@@ -393,10 +395,6 @@ int AIAction::getEfficiency()
{ {
efficiency = 100; efficiency = 100;
} }
else
{
efficiency = 0;
}
} }
if(p->game->hand->hasX()) if(p->game->hand->hasX())
{ {
@@ -426,7 +424,70 @@ int AIAction::getEfficiency()
} }
break; 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; efficiency = 0;
break; break;
default: 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) : 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) ActivatedAbilityTP(_id, card, _target, _cost, _tap, who), life(life)
{ {
aType = MTGAbility::LIFER;
} }
int AALifer::resolve() int AALifer::resolve()
@@ -990,6 +991,7 @@ AATapper::AATapper(int id, MTGCardInstance * card, MTGCardInstance * _target, Ma
ActivatedAbility(id, card, _cost, 0, doTap) ActivatedAbility(id, card, _cost, 0, doTap)
{ {
target = _target; target = _target;
aType = MTGAbility::TAPPER;
} }
int AATapper::resolve() int AATapper::resolve()
@@ -1021,6 +1023,7 @@ AAUntapper::AAUntapper(int id, MTGCardInstance * card, MTGCardInstance * _target
ActivatedAbility(id, card, _cost, 0, doTap) ActivatedAbility(id, card, _cost, 0, doTap)
{ {
target = _target; target = _target;
aType = MTGAbility::UNTAPPER;
} }
int AAUntapper::resolve() int AAUntapper::resolve()
+1 -1
View File
@@ -542,7 +542,7 @@ int MTGGameZone::hasColor(int value)
{ {
for (int i = 0; i < (nb_cards); i++) 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; return 1;
} }