this is the first draft of a simple ai combo system,
format is as follows
HINT#combo hold(blah|myhand)^until(blah|mygraveyard)^until(blah|opponentshand)^restriction{type(creature|mybattlefield)~morethan~2}^cast(blah) targeting(blah|mygraveyard)^totalmananneeded({g}{g}{r}{u}{2})
the ai can be told to hold more then one card, until as many condiations as you want are met, until( is a TC and can basically be used in a fasion of saying "hold arbor elf until you have a lord of atlantas in play and a gaint growth in you hand"
once the condiations are met you can later tell it to cast(gaint growth) targeting(arbor elf[fresh]|mybattlefield)...
I also included the whole of the games restrictions system...
so you can get really really creative with this so far.
the next thing I will do is ability targeting and card favoring.
This commit is contained in:
@@ -7,6 +7,7 @@ using std::string;
|
||||
using std::vector;
|
||||
|
||||
#include "AIPlayerBaka.h"
|
||||
#include "AllAbilities.h"
|
||||
|
||||
class ManaCost;
|
||||
class MTGAbility;
|
||||
@@ -18,6 +19,14 @@ public:
|
||||
string mAction;
|
||||
string mCombatAttackTip;
|
||||
vector<string>castOrder;
|
||||
vector<string>combos;
|
||||
//for preformance we disect the combo on first run.
|
||||
vector<string>partOfCombo;
|
||||
vector<string>hold;
|
||||
vector<string>until;
|
||||
vector<string>restrict;
|
||||
map<string,string>cardTargets;
|
||||
string manaNeeded;
|
||||
int mSourceId;
|
||||
AIHint(string line);
|
||||
};
|
||||
@@ -39,6 +48,8 @@ public:
|
||||
AIHints (AIPlayerBaka * player);
|
||||
AIAction * suggestAbility(ManaCost * potentialMana);
|
||||
bool HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
bool HintSaysItsForCombo(GameObserver* observer,MTGCardInstance * card = NULL);
|
||||
bool canWeCombo(GameObserver* observer,MTGCardInstance * card = NULL,AIPlayerBaka * Ai = NULL);
|
||||
vector<string> mCastOrder();
|
||||
void add(string line);
|
||||
~AIHints();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
class AIStats;
|
||||
class AIHints;
|
||||
class AIHint;
|
||||
|
||||
|
||||
//Would love to define those classes as private nested classes inside of AIPlayerBaka, but they are used by AIHints (which itself should be known only by AIPlayerBaka anyways)
|
||||
@@ -91,11 +92,14 @@ class AIPlayerBaka: public AIPlayer{
|
||||
virtual AIStats * getStats();
|
||||
|
||||
MTGCardInstance * nextCardToPlay;
|
||||
MTGCardInstance * activateCombo();
|
||||
TargetChooser * GetComboTc(GameObserver * observer, TargetChooser * tc = NULL);
|
||||
AIHints * hints;
|
||||
AIStats * stats;
|
||||
int oldGamePhase;
|
||||
float timer;
|
||||
virtual MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
|
||||
vector<MTGCardInstance*>comboCards;
|
||||
|
||||
//used by MomirPlayer, hence protected instead of private
|
||||
virtual int getEfficiency(OrderedAIAction * action);
|
||||
@@ -115,7 +119,9 @@ class AIPlayerBaka: public AIPlayer{
|
||||
};
|
||||
|
||||
vector<MTGAbility*>gotPayments;
|
||||
|
||||
AIPlayerBaka(GameObserver *observer, string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
|
||||
AIHint * comboHint;
|
||||
virtual int Act(float dt);
|
||||
void initTimer();
|
||||
virtual int computeActions();
|
||||
@@ -125,6 +131,7 @@ class AIPlayerBaka: public AIPlayer{
|
||||
virtual int affectCombatDamages(CombatStep step);
|
||||
virtual int canHandleCost(MTGAbility * ability);
|
||||
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL,MTGCardInstance * Chosencard = NULL,bool checkonly = false);
|
||||
virtual vector<MTGAbility*> canPayManaCost(MTGCardInstance * card = NULL, ManaCost * mCost = NULL){ return canPayMana(card, mCost);};
|
||||
|
||||
//used by AIHInts, therefore public instead of private :/
|
||||
virtual int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
|
||||
|
||||
@@ -4360,7 +4360,7 @@ public:
|
||||
MTGAbility(observer, id, _source)
|
||||
{
|
||||
counters = 0;
|
||||
std::vector<int8_t> _cost;
|
||||
std::vector<int16_t> _cost;
|
||||
_cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
_cost.push_back(4);
|
||||
cost = ManaCost(_cost, 1);
|
||||
@@ -4424,7 +4424,7 @@ public:
|
||||
MTGAbility(observer, _id, _source)
|
||||
{
|
||||
canprevent = 0;
|
||||
std::vector<int8_t> _cost;
|
||||
std::vector<int16_t> _cost;
|
||||
_cost.push_back(Constants::MTG_COLOR_ARTIFACT);
|
||||
_cost.push_back(2);
|
||||
cost = ManaCost(_cost, 1);
|
||||
@@ -4520,7 +4520,7 @@ public:
|
||||
AFarmstead(GameObserver* observer, int _id, MTGCardInstance * source, MTGCardInstance * _target) :
|
||||
ActivatedAbility(observer, _id, source, 0, 1)
|
||||
{
|
||||
std::vector<int8_t> _cost;
|
||||
std::vector<int16_t> _cost;
|
||||
_cost.push_back(Constants::MTG_COLOR_WHITE);
|
||||
_cost.push_back(2);
|
||||
setCost(NEW ManaCost(_cost, 1), true);
|
||||
|
||||
@@ -66,9 +66,15 @@ public:
|
||||
static void ThreadProc(void* inParam);
|
||||
void handleResults(GameObserver* aGame){
|
||||
mMutex.lock();
|
||||
totalTestGames++;
|
||||
if (aGame->didWin(aGame->players[1]))
|
||||
{
|
||||
testPlayer2Victories++;
|
||||
totalTestGames++;
|
||||
}
|
||||
else if( aGame->didWin(aGame->players[0]))
|
||||
{
|
||||
totalTestGames++;
|
||||
}
|
||||
mMutex.unlock();
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@ class ManaCost
|
||||
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
|
||||
|
||||
protected:
|
||||
std::vector<int8_t> cost;
|
||||
std::vector<int16_t> cost;
|
||||
std::vector<ManaCostHybrid> hybrids;
|
||||
|
||||
virtual void init();
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
int hasSpecificX();
|
||||
int xColor;
|
||||
int hasAnotherCost();
|
||||
ManaCost(std::vector<int8_t>& _cost, int nb_elems = 1);
|
||||
ManaCost(std::vector<int16_t>& _cost, int nb_elems = 1);
|
||||
ManaCost();
|
||||
~ManaCost();
|
||||
ManaCost(ManaCost * _manaCost);
|
||||
@@ -89,8 +89,8 @@ public:
|
||||
ExtraCost * getExtraCost(unsigned int i);
|
||||
|
||||
int addHybrid(int c1, int v1, int c2, int v2);
|
||||
int tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids,std::vector<int8_t>& diff);
|
||||
void randomDiffHybrids(ManaCost * _cost, std::vector<int8_t>& diff);
|
||||
int tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids,std::vector<int16_t>& diff);
|
||||
void randomDiffHybrids(ManaCost * _cost, std::vector<int16_t>& diff);
|
||||
int add(ManaCost * _cost);
|
||||
int remove(ManaCost * _cost);
|
||||
int removeAll(int color);
|
||||
|
||||
Reference in New Issue
Block a user