AIPlayer minor tweaks:

- In order to clarify getEfficiency, started creating "getEfficiency" functions specific to each type of ability (see example with Damager). This won't reduce the file size but should make things bit clearer
- Minor cleanup of getEfficiency
- bug fixes in getEfficiency
This commit is contained in:
wagic.the.homebrew
2011-09-21 15:10:06 +00:00
parent 11095f3339
commit 15f0143a8f
10 changed files with 413 additions and 2489 deletions

View File

@@ -28,6 +28,7 @@ class AIAction
protected:
static int currentId;
public:
Player * owner;
MTGAbility * ability;
NestedAbility * nability;
Player * player;
@@ -38,27 +39,27 @@ public:
Targetable * playerAbilityTarget;
//player targeting through abilities is handled completely seperate from spell targeting.
AIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL)
: ability(a), player(NULL), click(c), target(t),playerAbilityTarget(NULL)
AIAction(Player * owner, MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL)
: owner(owner), ability(a), player(NULL), click(c), target(t),playerAbilityTarget(NULL)
{
id = currentId++;
};
AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL);
AIAction(Player * owner, MTGCardInstance * c, MTGCardInstance * t = NULL);
AIAction(Player * p)//player targeting through spells
: ability(NULL), player(p), click(NULL), target(NULL),playerAbilityTarget(NULL)
AIAction(Player * owner, Player * p)//player targeting through spells
: owner(owner), ability(NULL), player(p), click(NULL), target(NULL),playerAbilityTarget(NULL)
{
};
AIAction(MTGAbility * a, MTGCardInstance * c, vector<Targetable*>targetCards)
: ability(a), player(NULL), click(c), mAbilityTargets(targetCards),playerAbilityTarget(NULL)
AIAction(Player * owner, MTGAbility * a, MTGCardInstance * c, vector<Targetable*>targetCards)
: owner(owner), ability(a), player(NULL), click(c), mAbilityTargets(targetCards),playerAbilityTarget(NULL)
{
id = currentId++;
};
AIAction(MTGAbility * a, Player * p, MTGCardInstance * c)//player targeting through abilities.
: ability(a), click(c),target(NULL), playerAbilityTarget(p)
AIAction(Player * owner, MTGAbility * a, Player * p, MTGCardInstance * c)//player targeting through abilities.
: owner(owner), ability(a), click(c),target(NULL), playerAbilityTarget(p)
{
id = currentId++;
};

View File

@@ -2,6 +2,7 @@
#define _AI_PLAYER_BAKA_H_
#include "AIPlayer.h"
#include "AllAbilities.h"
class AIStats;
class AIHints;
@@ -12,33 +13,37 @@ class AIHints;
class OrderedAIAction: public AIAction
{
protected:
Player * getPlayerTarget();
public:
int efficiency;
OrderedAIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL)
: AIAction(a, c, t), efficiency(-1)
OrderedAIAction(Player * owner, MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL)
: AIAction(owner, a, c, t), efficiency(-1)
{
};
OrderedAIAction(MTGCardInstance * c, MTGCardInstance * t = NULL);
OrderedAIAction(Player * owner, MTGCardInstance * c, MTGCardInstance * t = NULL);
OrderedAIAction(Player * p)//player targeting through spells
: AIAction(p), efficiency(-1)
OrderedAIAction(Player * owner, Player * p)//player targeting through spells
: AIAction(owner,p), efficiency(-1)
{
};
OrderedAIAction(MTGAbility * a, MTGCardInstance * c, vector<Targetable*>targetCards)
: AIAction(a, c, targetCards), efficiency(-1)
OrderedAIAction(Player * owner, MTGAbility * a, MTGCardInstance * c, vector<Targetable*>targetCards)
: AIAction(owner,a, c, targetCards), efficiency(-1)
{
};
OrderedAIAction(MTGAbility * a, Player * p, MTGCardInstance * c)//player targeting through abilities.
: AIAction(a, p, c), efficiency(-1)
OrderedAIAction(Player * owner, MTGAbility * a, Player * p, MTGCardInstance * c)//player targeting through abilities.
: AIAction(owner, a, p, c), efficiency(-1)
{
};
int getEfficiency();
// Functions depending on the type of Ability
int getEfficiency(AADamager * aad);
};
// compares Abilities efficiency
@@ -60,7 +65,7 @@ typedef std::map<OrderedAIAction, int, CmpAbilities> RankingContainer;
class AIPlayerBaka: public AIPlayer{
private:
protected:
virtual int orderBlockers();
virtual int combatDamages();
virtual int interruptIfICan();
@@ -84,7 +89,6 @@ private:
virtual AIStats * getStats();
protected:
MTGCardInstance * nextCardToPlay;
AIHints * hints;
AIStats * stats;

View File

@@ -1,17 +1,18 @@
#include "config.h"
#ifdef AI_CHANGE_TESTING
#ifndef _AI_PLAYER_BAKA_B_H_
#include "config.h"
#ifdef AI_CHANGE_TESTING
#ifndef _AI_PLAYER_BAKA_B_H_
#define _AI_PLAYER_BAKA_B_H_
#include "AIPlayerBaka.h"
#include "AllAbilities.h"
class AIStats;
class AIHints;
class AIPlayerBakaB: public AIPlayerBaka{
private:
protected:
int orderBlockers();
int combatDamages();
int interruptIfICan();
@@ -36,16 +37,16 @@ private:
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();
//used by MomirPlayer, hence protected instead of private
virtual int getEfficiency(OrderedAIAction * action);
public:
AIPlayerBakaB(string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
@@ -62,7 +63,7 @@ private:
//used by AIHInts, therefore public instead of private :/
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
};
#endif
#endif
#endif

View File

@@ -86,8 +86,8 @@ class MTGGameZone {
void cleanupPhase();
void beforeBeginPhase();
int countByType(const char * value);
int countByCanTarget(TargetChooser * tc);
unsigned int countByType(const char * value);
unsigned int countByCanTarget(TargetChooser * tc);
MTGCardInstance * findByName(string name);
//returns true if one of the cards in the zone has the ability