Files
wagic/projects/mtg/include/AIPlayer.h
omegablast2002@yahoo.com ed03d2f3ef added optimizing of opponents hand if the opponent deck is listed as "easy". slight optimize if listed as "normal" none if listed as "hard" this provides slightly more challange from even poorly constructed Ai decks. taught Ai to pump creatures during combat, and more so if its heading directly at player, taught Ai that its better to use "becomes" and "transforms" during first main. this allow its to actually attack with the manlands ect.
new ability lord...teach(whatever[whatever]) ability.
teach is a targeted lord, it takes the cards current target and lords it the ability. im aware of a tiny memleak it contains, but the leak is happening on parser lvl, so i need more eyes to look at it. teach is ideally used for equipment, and was designed to fix issue 244 taught abilities are not given to the source cards.

forced Ai to pay for sunburst correctly. it was choosing to pay with all of one type of mana. now it pays either max or 1 from max sunburst.

added a tiny double check for Ai to try and find something to use if it suddenly has mana in its pool. it is only a single check in a turn, but i notice it actually does slightly improve the usages of dark ritual and foreach mana producers. ideally i wanted it to check EVERYTIME. but i could not achieve it without putting the game in danger of looping. so once is better then none :/

fixed a bug with affinity where it was not counting duel lands, this is becuase of not setting it up correctly for lands with multiple types SORRY!
2010-11-06 06:59:43 +00:00

116 lines
3.3 KiB
C++

/*
* Wagic, The Homebrew ?! is licensed under the BSD license
* See LICENSE in the Folder's root
* http://wololo.net/wagic/
*/
#ifndef _IAPLAYER_H
#define _IAPLAYER_H
#include "Player.h"
#include <queue>
using std::queue;
#define INFO_NBCREATURES 0
#define INFO_CREATURESPOWER 1
#define INFO_CREATURESRANK 2
#define INFO_CREATURESTOUGHNESS 3
#define INFO_CREATURESATTACKINGPOWER 4
class AIStats;
class AIAction{
protected:
int efficiency;
static int currentId;
public:
MTGAbility * ability;
NestedAbility * nability;
Player * player;
int id;
bool checked;
MTGCardInstance * click;
MTGCardInstance * target; // TODO Improve
AIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL):ability(a),click(c),target(t){player = NULL; efficiency = -1; id = currentId++;};
AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL):click(c),target(t){player = NULL; ability = NULL; efficiency = -1; id = currentId++;};
AIAction(Player * p):player(p){ability = NULL; target = NULL; click = NULL; efficiency = -1;};
int getEfficiency();
int Act();
};
class CmpAbilities { // compares Abilities efficiency
public:
bool operator()(AIAction * a1, AIAction * a2) const {
int e1 = a1->getEfficiency();
int e2 = a2->getEfficiency();
if (e1 == e2) return a1->id < a2->id;
return (e1 > e2);
}
};
class AIPlayer: public Player{
protected:
MTGCardInstance * nextCardToPlay;
queue<AIAction *> clickstream;
void tapLandsForMana(ManaCost * cost, MTGCardInstance * card = NULL);
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);
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
AIStats * getStats();
//Variables used by Test suite
public:
int agressivity;
bool Checked;
bool forceBestAbilityUse;
void End(){};
virtual int displayStack() {return 0;};
int receiveEvent(WEvent * event);
void Render();
AIStats * stats;
ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
AIPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
virtual ~AIPlayer();
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget =NULL);
virtual int Act(float dt);
virtual int affectCombatDamages(CombatStep);
int isAI(){return 1;};
int canHandleCost(MTGAbility * ability);
int selectAbility();
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, map<AIAction *, int,CmpAbilities> * ranking);
int useAbility();
virtual int getEfficiency(AIAction * action);
};
class AIPlayerBaka: public AIPlayer{
protected:
int oldGamePhase;
float timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
public:
int deckId;
AIPlayerBaka(MTGDeck * deck, string deckFile, string deckfileSmall, string avatarFile);
virtual int Act(float dt);
void initTimer();
virtual int computeActions();
};
class AIPlayerFactory{
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, Player * opponent, int deckid = 0);
};
#endif