From ef942d46b5b123ac5e119cac13969bf0ffdee57c Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Tue, 26 Apr 2011 14:10:57 +0000 Subject: [PATCH] 2 changes, comparing counters to p instead of isAi(), and hope to close off an edge case where ai would get stuck cycling through setting the target of a may ability. caught it stuck 2 times while watching demo. i watched demo for close to an hour without seeing any adverse effect, and without getting stuck, tho this is so hard to debug, since there is no call stack loaded for this case when it happens. --- projects/mtg/src/AIPlayer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 6b0cded50..a0040dee9 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -431,12 +431,12 @@ int AIAction::getEfficiency() { if(cc && _target) { - if(_target && _target->controller()->isAI() && cc->toughness>=0) + if(_target && _target->controller() == p && cc->toughness>=0) { efficiency = 90; } - if(_target && !_target->controller()->isAI() && ((_target->toughness + cc->toughness <= 0 && _target->toughness) || (cc->toughness < 0 && cc->power < 0))) + if(_target && _target->controller() != p && ((_target->toughness + cc->toughness <= 0 && _target->toughness) || (cc->toughness < 0 && cc->power < 0))) { efficiency = 90; @@ -968,8 +968,14 @@ int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCardInst { case TARGET_CARD: { - MTGCardInstance * card = ((MTGCardInstance *) potentialTargets[i]); - clickstream.push(NEW AIAction(card)); + if(!Choosencard) + { + MTGCardInstance * card = ((MTGCardInstance *) potentialTargets[i]); + clickstream.push(NEW AIAction(card)); + Choosencard = card; + } + //can't be 100% positive that this wont have an adverse side-effect + //hoping this fills a edge case where ai will keep trying to choose a target for a card which it already has a target for. return 1; break; }