From a7aeb7efe55afcc4a4a42c03d3ac3b34e0d47e2c Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Wed, 13 Mar 2013 01:11:58 +0000 Subject: [PATCH] fix for a bug in combohint. ai will now rarely want to use a card outside of a combo if it is to be held for a combo --- projects/mtg/src/AIHints.cpp | 8 ++++++-- projects/mtg/src/AIPlayerBaka.cpp | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/mtg/src/AIHints.cpp b/projects/mtg/src/AIHints.cpp index 0a4e8766c..66a355b70 100644 --- a/projects/mtg/src/AIHints.cpp +++ b/projects/mtg/src/AIHints.cpp @@ -118,7 +118,7 @@ bool AIHints::HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card) //here we disect the different parts of a given combo part = hints[i]->combos[cPart]; hints[i]->partOfCombo = split(part,'^'); - for(unsigned int dPart = 0; dPart < hints[i]->partOfCombo.size(); dPart++) + for(size_t dPart = hints[i]->partOfCombo.size()-1;dPart >= 0;dPart--) { vectorasTc; asTc = parseBetween(hints[i]->partOfCombo[dPart],"hold(",")"); @@ -142,7 +142,9 @@ bool AIHints::HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card) asTc = parseBetween(hints[i]->partOfCombo[dPart],"cast(",")"); if(asTc.size()) { - hints[i]->cardTargets[asTc[1]] = parseBetween(hints[i]->partOfCombo[dPart],"targeting(",")")[1]; + vectorcht = parseBetween(hints[i]->partOfCombo[dPart],"targeting(",")"); + if(cht.size()) + hints[i]->cardTargets[asTc[1]] = cht[1]; } asTc = parseBetween(hints[i]->partOfCombo[dPart],"totalmananeeded(",")"); if(asTc.size()) @@ -150,6 +152,8 @@ bool AIHints::HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card) hints[i]->manaNeeded = asTc[1]; asTc.clear(); } + if(dPart == 0) + break; } } }//we collect the peices of a combo on first run. diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index f2cb3e3d8..b84b43277 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -1736,9 +1736,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty } else { - int chance = int(getRandomGenerator()->random() % 100); - if(chance > 1) - continue;//1% chance to just continue evaluating the card to cast. + nextCardToPlay = NULL; + continue; } } int currentCost = card->getManaCost()->getConvertedCost();