Fixed a bug where Ai was able to do actions such as sacrifice Mogg fanatic 3 time in a row by tripping over its own clickstream, added gaurds to selectAbility() function calls to prevent Ai from running multiple instences of selectAbility before its completed running another which occurs when Ai is offered an interupt after player cast/does an action.
this also fixes the spamming of Abilities like Ai atempting to untap something more then once, or Ai uses regenerate ability multiple times on the same creature. there will be no noticible difference in Ai game play except now it actually doesnt do the above mentioned bugs.
This commit is contained in:
@@ -59,6 +59,7 @@ protected:
|
||||
//Variables used by Test suite
|
||||
MTGCardInstance * nextCardToPlay;
|
||||
queue<AIAction *> clickstream;
|
||||
bool findingAbility;
|
||||
void tapLandsForMana(ManaCost * cost, MTGCardInstance * card = NULL);
|
||||
int orderBlockers();
|
||||
int combatDamages();
|
||||
|
||||
@@ -95,7 +95,11 @@ int AIMomirPlayer::computeActions()
|
||||
int currentGamePhase = g->getCurrentGamePhase();
|
||||
if (g->isInterrupting == this)
|
||||
{ // interrupting
|
||||
selectAbility();
|
||||
if(!findingAbility)
|
||||
{
|
||||
AIPlayer::findingAbility = true;
|
||||
selectAbility();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (p == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
|
||||
@@ -129,7 +133,11 @@ int AIMomirPlayer::computeActions()
|
||||
break;
|
||||
}
|
||||
case Constants::MTG_PHASE_SECONDMAIN:
|
||||
selectAbility();
|
||||
if(!findingAbility)
|
||||
{
|
||||
AIPlayer::findingAbility = true;
|
||||
selectAbility();
|
||||
}
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -629,17 +629,25 @@ int AIPlayer::selectAbility()
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!clickstream.size())
|
||||
{
|
||||
DebugTrace("AIPlayer:Using Activated ability");
|
||||
tapLandsForMana(a->ability->cost, a->click);
|
||||
clickstream.push(a);
|
||||
clickstream.push(a);
|
||||
}
|
||||
else
|
||||
{
|
||||
a = NULL;
|
||||
}
|
||||
}
|
||||
map<AIAction *, int, CmpAbilities>::iterator it2;
|
||||
for (it2 = ranking.begin(); it2 != ranking.end(); it2++)
|
||||
{
|
||||
if (a != it2->first)
|
||||
if (a && a != it2->first)
|
||||
delete (it2->first);
|
||||
}
|
||||
}
|
||||
AIPlayer::findingAbility = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1145,6 +1153,7 @@ int AIPlayerBaka::computeActions()
|
||||
{
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
Player * p = g->currentPlayer;
|
||||
AIPlayer::findingAbility = false;
|
||||
if (!(g->currentlyActing() == this))
|
||||
return 0;
|
||||
if (g->mLayers->actionLayer()->menuObject)
|
||||
@@ -1157,7 +1166,11 @@ int AIPlayerBaka::computeActions()
|
||||
int currentGamePhase = g->getCurrentGamePhase();
|
||||
if (g->isInterrupting == this)
|
||||
{ // interrupting
|
||||
selectAbility();
|
||||
if(!findingAbility)
|
||||
{
|
||||
AIPlayer::findingAbility = true;
|
||||
selectAbility();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (p == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
|
||||
@@ -1178,7 +1191,11 @@ int AIPlayerBaka::computeActions()
|
||||
potential = true;
|
||||
}
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "land");
|
||||
if(!findingAbility)
|
||||
{
|
||||
AIPlayer::findingAbility = true;
|
||||
selectAbility();
|
||||
}
|
||||
//look for the most expensive creature we can afford
|
||||
if (castrestrictedspell == 0 && nospellinstant == 0)
|
||||
{
|
||||
@@ -1212,7 +1229,11 @@ int AIPlayerBaka::computeActions()
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
selectAbility();
|
||||
if(!findingAbility)
|
||||
{
|
||||
AIPlayer::findingAbility = true;
|
||||
selectAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1261,7 +1282,11 @@ int AIPlayerBaka::computeActions()
|
||||
}
|
||||
else
|
||||
{
|
||||
selectAbility();
|
||||
if(!findingAbility)
|
||||
{
|
||||
AIPlayer::findingAbility = true;
|
||||
selectAbility();
|
||||
}
|
||||
}
|
||||
if (p->getManaPool()->getConvertedCost() > 0 && Checked == false)//not the best thing ever, but allows the Ai a chance to double check if its mana pool has something before moving on, atleast one time.
|
||||
{
|
||||
@@ -1277,7 +1302,11 @@ int AIPlayerBaka::computeActions()
|
||||
Checked = false;
|
||||
break;
|
||||
default:
|
||||
selectAbility();
|
||||
if(!findingAbility)
|
||||
{
|
||||
AIPlayer::findingAbility = true;
|
||||
selectAbility();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user