Adding a system to compare two AI implementations (AIPlayerBaka and AIPlayerBakaB). This can be used to make sure a change to the AI is not making the AI weaker, for example.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#define _IAPLAYER_H
|
||||
|
||||
#include "Player.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <queue>
|
||||
using std::queue;
|
||||
@@ -68,7 +69,9 @@ public:
|
||||
|
||||
|
||||
class AIPlayer: public Player{
|
||||
|
||||
protected:
|
||||
bool mFastTimerMode;
|
||||
queue<AIAction *> clickstream;
|
||||
int clickMultiTarget(TargetChooser * tc,vector<Targetable*>&potentialTargets);
|
||||
int clickSingleTarget(TargetChooser * tc,vector<Targetable*>&potentialTargets, MTGCardInstance * Choosencard = NULL);
|
||||
@@ -93,6 +96,8 @@ public:
|
||||
|
||||
int isAI(){return 1;};
|
||||
|
||||
void setFastTimerMode(bool mode = true) { mFastTimerMode = mode; };
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -100,6 +105,9 @@ public:
|
||||
class AIPlayerFactory{
|
||||
public:
|
||||
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0);
|
||||
#ifdef AI_CHANGE_TESTING
|
||||
AIPlayer * createAIPlayerTest(MTGAllCards * collection, Player * opponent, int deckid = 0);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -61,11 +61,6 @@ typedef std::map<OrderedAIAction, int, CmpAbilities> RankingContainer;
|
||||
|
||||
class AIPlayerBaka: public AIPlayer{
|
||||
private:
|
||||
|
||||
MTGCardInstance * nextCardToPlay;
|
||||
AIHints * hints;
|
||||
AIStats * stats;
|
||||
|
||||
int orderBlockers();
|
||||
int combatDamages();
|
||||
int interruptIfICan();
|
||||
@@ -91,6 +86,9 @@ private:
|
||||
AIStats * getStats();
|
||||
|
||||
protected:
|
||||
MTGCardInstance * nextCardToPlay;
|
||||
AIHints * hints;
|
||||
AIStats * stats;
|
||||
int oldGamePhase;
|
||||
float timer;
|
||||
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
|
||||
@@ -122,7 +120,7 @@ private:
|
||||
virtual ~AIPlayerBaka();
|
||||
int affectCombatDamages(CombatStep step);
|
||||
int canHandleCost(MTGAbility * ability);
|
||||
int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget =NULL,MTGCardInstance * Choosencard = NULL,bool checkonly = false);
|
||||
int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL,MTGCardInstance * Chosencard = NULL,bool checkonly = false);
|
||||
|
||||
//used by AIHInts, therefore public instead of private :/
|
||||
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
|
||||
|
||||
68
projects/mtg/include/AIPlayerBakaB.h
Normal file
68
projects/mtg/include/AIPlayerBakaB.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "config.h"
|
||||
#ifdef AI_CHANGE_TESTING
|
||||
|
||||
#ifndef _AI_PLAYER_BAKA_B_H_
|
||||
#define _AI_PLAYER_BAKA_B_H_
|
||||
|
||||
#include "AIPlayerBaka.h"
|
||||
|
||||
class AIStats;
|
||||
class AIHints;
|
||||
|
||||
|
||||
class AIPlayerBakaB: public AIPlayerBaka{
|
||||
private:
|
||||
int orderBlockers();
|
||||
int combatDamages();
|
||||
int interruptIfICan();
|
||||
int chooseAttackers();
|
||||
int chooseBlockers();
|
||||
int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
|
||||
int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
|
||||
|
||||
|
||||
// returns 1 if the AI algorithm supports a given cost (ex:simple mana cost), 0 otherwise (ex: cost involves Sacrificing a target)
|
||||
int CanHandleCost(ManaCost * cost);
|
||||
|
||||
//Tries to play an ability recommended by the deck creator
|
||||
int selectHintAbility();
|
||||
|
||||
vector<MTGAbility*> canPayMana(MTGCardInstance * card = NULL,ManaCost * mCost = NULL);
|
||||
vector<MTGAbility*> canPaySunBurst(ManaCost * mCost = NULL);
|
||||
|
||||
MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
|
||||
int selectMenuOption();
|
||||
int useAbility();
|
||||
|
||||
AIStats * getStats();
|
||||
|
||||
protected:
|
||||
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
|
||||
|
||||
//used by MomirPlayer, hence protected instead of private
|
||||
virtual int getEfficiency(OrderedAIAction * action);
|
||||
bool payTheManaCost(ManaCost * cost, MTGCardInstance * card = NULL,vector<MTGAbility*> gotPayment = vector<MTGAbility*>());
|
||||
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
|
||||
ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
|
||||
int selectAbility();
|
||||
|
||||
public:
|
||||
|
||||
AIPlayerBakaB(string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
|
||||
virtual int Act(float dt);
|
||||
void initTimer();
|
||||
virtual int computeActions();
|
||||
virtual void Render();
|
||||
virtual int receiveEvent(WEvent * event);
|
||||
virtual ~AIPlayerBakaB();
|
||||
int affectCombatDamages(CombatStep step);
|
||||
int canHandleCost(MTGAbility * ability);
|
||||
int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget =NULL,MTGCardInstance * Choosencard = NULL,bool checkonly = false);
|
||||
|
||||
//used by AIHInts, therefore public instead of private :/
|
||||
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -30,10 +30,11 @@ class Rules;
|
||||
enum
|
||||
{
|
||||
PLAYER_TYPE_CPU = 0,
|
||||
PLAYER_TYPE_HUMAN=1,
|
||||
PLAYER_TYPE_TESTSUITE=2,
|
||||
PLAYER_TYPE_HUMAN = 1,
|
||||
PLAYER_TYPE_TESTSUITE = 2,
|
||||
PLAYER_TYPE_CPU_TEST = 3,
|
||||
#ifdef NETWORK_SUPPORT
|
||||
PLAYER_TYPE_REMOTE=3
|
||||
PLAYER_TYPE_REMOTE = 4
|
||||
#endif //NETWORK_SUPPORT
|
||||
};
|
||||
|
||||
|
||||
@@ -53,6 +53,13 @@ public:
|
||||
#ifdef TESTSUITE
|
||||
void loadTestSuitePlayers();
|
||||
#endif
|
||||
|
||||
#ifdef AI_CHANGE_TESTING
|
||||
int totalTestGames;
|
||||
int testPlayer2Victories;
|
||||
int totalAIDecks;
|
||||
#endif
|
||||
|
||||
virtual void ButtonPressed(int ControllerId, int ControlId);
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
|
||||
@@ -40,6 +40,7 @@ enum
|
||||
#endif //NETWORK_SUPPORT
|
||||
SUBMENUITEM_DEMO,
|
||||
SUBMENUITEM_TESTSUITE,
|
||||
SUBMENUITEM_TESTAI,
|
||||
SUBMENUITEM_END_OFFSET
|
||||
};
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
// Debug options - comment/uncomment as needed
|
||||
//#define DEBUG_CACHE
|
||||
#ifdef _DEBUG
|
||||
#ifdef WIN32
|
||||
#define AI_CHANGE_TESTING
|
||||
#endif
|
||||
//#define RENDER_AI_STATS
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user