From 9ffe7349e228a6d43de18898bea436f14c00e15b Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Wed, 10 Apr 2013 02:38:52 +0000 Subject: [PATCH] added a hint that allows you to override how ai views a cards effects. #HINT:good(icy prison) ai will act as though the effects of this card are now good, choosing to cast it on it's own creatures. #HINT:bad(ancestral recall) ai will now use this card targeting the opponent. good in cases where you are trying to mill the opponent the effects in wagic have gotten so complex that ai simply has no idea what some cards should target. this helps in most of the cases. --- projects/mtg/include/AIHints.h | 4 +++ projects/mtg/src/AIHints.cpp | 52 +++++++++++++++++++++++++++++++ projects/mtg/src/AIPlayerBaka.cpp | 8 +++++ 3 files changed, 64 insertions(+) diff --git a/projects/mtg/include/AIHints.h b/projects/mtg/include/AIHints.h index e15b64dfe..7a0c7904f 100644 --- a/projects/mtg/include/AIHints.h +++ b/projects/mtg/include/AIHints.h @@ -21,6 +21,8 @@ public: string mCombatBlockTip; string mCombatAlwaysBlockTip; string mCombatAlwaysAttackTip; + string mCardEffGood; + string mCardEffBad; vectorcastOrder; vectorcombos; //for preformance we disect the combo on first run. @@ -55,6 +57,8 @@ public: bool HintSaysAlwaysAttack(GameObserver* observer,MTGCardInstance * card = NULL); bool HintSaysDontBlock(GameObserver* observer,MTGCardInstance * card = NULL); bool HintSaysAlwaysBlock(GameObserver* observer,MTGCardInstance * card = NULL); + bool AIHints::HintSaysCardIsGood(GameObserver* observer,MTGCardInstance * card); + bool AIHints::HintSaysCardIsBad(GameObserver* observer,MTGCardInstance * card); bool HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card = NULL); bool canWeCombo(GameObserver* observer,MTGCardInstance * card = NULL,AIPlayerBaka * Ai = NULL); vector mCastOrder(); diff --git a/projects/mtg/src/AIHints.cpp b/projects/mtg/src/AIHints.cpp index 1428e1a91..f61686598 100644 --- a/projects/mtg/src/AIHints.cpp +++ b/projects/mtg/src/AIHints.cpp @@ -54,6 +54,18 @@ AIHint::AIHint(string _line) mCombatAlwaysBlockTip = splitAlwaysBlock[1]; } + vector splitSetEffgood = parseBetween(action, "good(", ")"); + if(splitSetEffgood.size()) + { + mCardEffGood = splitSetEffgood[1]; + } + + vector splitSetEffbad = parseBetween(action, "bad(", ")"); + if(splitSetEffbad.size()) + { + mCardEffBad = splitSetEffbad[1]; + } + vector splitCastOrder = parseBetween(action, "castpriority(", ")"); if(splitCastOrder.size()) { @@ -178,6 +190,46 @@ bool AIHints::HintSaysAlwaysBlock(GameObserver* observer,MTGCardInstance * card) return false; } +bool AIHints::HintSaysCardIsGood(GameObserver* observer,MTGCardInstance * card) +{ + TargetChooserFactory tfc(observer); + TargetChooser * hintTc = NULL; + for(unsigned int i = 0; i < hints.size();i++) + { + if (hints[i]->mCardEffGood.size()) + { + hintTc = tfc.createTargetChooser(hints[i]->mCardEffGood,card); + if(hintTc && hintTc->canTarget(card,true)) + { + SAFE_DELETE(hintTc); + return true; + } + SAFE_DELETE(hintTc); + } + } + return false; +} + +bool AIHints::HintSaysCardIsBad(GameObserver* observer,MTGCardInstance * card) +{ + TargetChooserFactory tfc(observer); + TargetChooser * hintTc = NULL; + for(unsigned int i = 0; i < hints.size();i++) + { + if (hints[i]->mCardEffBad.size()) + { + hintTc = tfc.createTargetChooser(hints[i]->mCardEffBad,card); + if(hintTc && hintTc->canTarget(card,true)) + { + SAFE_DELETE(hintTc); + return true; + } + SAFE_DELETE(hintTc); + } + } + return false; +} + bool AIHints::HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card) { TargetChooserFactory tfc(observer); diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index 907be04b6..87d9a1c30 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -1461,6 +1461,14 @@ int AIPlayerBaka::interruptIfICan() int AIPlayerBaka::effectBadOrGood(MTGCardInstance * card, int mode, TargetChooser * tc) { + if(hints && hints->HintSaysCardIsGood(observer,card)) + { + return BAKA_EFFECT_GOOD; + } + if(hints && hints->HintSaysCardIsBad(observer,card)) + { + return BAKA_EFFECT_BAD; + } int id = card->getMTGId(); AbilityFactory af(observer); int autoGuess = af.magicText(id, NULL, card, mode, tc);