Some preliminary work for minmax
This commit is contained in:
@@ -12,6 +12,8 @@ using std::vector;
|
||||
class ManaCost;
|
||||
class MTGAbility;
|
||||
|
||||
namespace AI {
|
||||
|
||||
class AIHint
|
||||
{
|
||||
public:
|
||||
@@ -66,4 +68,6 @@ public:
|
||||
~AIHints();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "AIPlayerBaka.h"
|
||||
|
||||
namespace AI {
|
||||
|
||||
class AIMomirPlayer: public AIPlayerBaka
|
||||
{
|
||||
public:
|
||||
@@ -14,4 +16,6 @@ public:
|
||||
MTGAbility * getMomirAbility();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,20 +18,44 @@
|
||||
#include "Player.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
using std::queue;
|
||||
using std::vector;
|
||||
|
||||
|
||||
namespace AI {
|
||||
|
||||
class AIStats;
|
||||
class AIPlayer;
|
||||
|
||||
|
||||
class Action
|
||||
{
|
||||
protected:
|
||||
GameObserver* m_pObserver;
|
||||
bool parseLine(const string& s);
|
||||
|
||||
public:
|
||||
Action(GameObserver* g, const string& s) : m_pObserver(g)
|
||||
{
|
||||
parseLine(s);
|
||||
};
|
||||
|
||||
friend ostream& operator<<(ostream&, const Action&);
|
||||
friend istream& operator>>(istream&, Action&);
|
||||
};
|
||||
|
||||
class AIAction
|
||||
{
|
||||
protected:
|
||||
int clickMultiAct(vector<Targetable*>&actionTargets);
|
||||
|
||||
public:
|
||||
AIPlayer * owner;
|
||||
MTGAbility * ability;
|
||||
NestedAbility * nability;
|
||||
Player * player;
|
||||
int id;
|
||||
// int id;
|
||||
MTGCardInstance * click;
|
||||
MTGCardInstance * target; // TODO Improve
|
||||
vector<Targetable*>mAbilityTargets;
|
||||
@@ -60,7 +84,6 @@ public:
|
||||
{
|
||||
};
|
||||
int Act();
|
||||
int clickMultiAct(vector<Targetable*>&actionTargets);
|
||||
};
|
||||
|
||||
|
||||
@@ -77,8 +100,20 @@ protected:
|
||||
int clickMultiTarget(TargetChooser * tc,vector<Targetable*>&potentialTargets);
|
||||
int clickSingleTarget(TargetChooser * tc,vector<Targetable*>&potentialTargets, MTGCardInstance * Choosencard = NULL);
|
||||
RandomGenerator randomGenerator;
|
||||
virtual bool canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
|
||||
virtual bool canPlay(MTGCardInstance * card);
|
||||
virtual int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
|
||||
|
||||
virtual int createAbilityPotentialsActions(MTGAbility * a, MTGCardInstance * c, vector<AIAction>& actions);
|
||||
|
||||
public:
|
||||
enum {
|
||||
INFO_NBCREATURES,
|
||||
INFO_CREATURESPOWER,
|
||||
INFO_CREATURESRANK,
|
||||
INFO_CREATURESTOUGHNESS,
|
||||
INFO_CREATURESATTACKINGPOWER
|
||||
};
|
||||
|
||||
//These variables are used by TestSuite and Rules.cpp... TODO change that?
|
||||
int agressivity;
|
||||
@@ -89,7 +124,7 @@ public:
|
||||
virtual int receiveEvent(WEvent * event);
|
||||
virtual void Render();
|
||||
|
||||
AIPlayer(GameObserver *observer, string deckFile, string deckFileSmall, MTGDeck * deck = NULL);
|
||||
AIPlayer(GameObserver *observer, string deckFile, string deckFileSmall, string avatarFile, MTGDeck * deck = NULL);
|
||||
virtual ~AIPlayer();
|
||||
|
||||
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL, MTGCardInstance * Chosencard = NULL, bool checkonly = false) = 0;
|
||||
@@ -116,5 +151,6 @@ class AIPlayerFactory{
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "AIPlayer.h"
|
||||
#include "AllAbilities.h"
|
||||
|
||||
namespace AI {
|
||||
|
||||
class AIStats;
|
||||
class AIHints;
|
||||
class AIHint;
|
||||
@@ -57,7 +59,7 @@ public:
|
||||
OrderedAIAction* a2Ptr = const_cast<OrderedAIAction*>(&a2);
|
||||
int e1 = a1Ptr->getEfficiency();
|
||||
int e2 = a2Ptr->getEfficiency();
|
||||
if (e1 == e2) return a1Ptr->id < a2Ptr->id;
|
||||
// if (e1 == e2) return a1Ptr->id < a2Ptr->id;
|
||||
return (e1 > e2);
|
||||
}
|
||||
};
|
||||
@@ -72,7 +74,7 @@ class AIPlayerBaka: public AIPlayer{
|
||||
virtual int interruptIfICan();
|
||||
virtual int chooseAttackers();
|
||||
virtual int chooseBlockers();
|
||||
virtual int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
|
||||
virtual bool canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
|
||||
virtual int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
|
||||
|
||||
|
||||
@@ -105,19 +107,10 @@ class AIPlayerBaka: public AIPlayer{
|
||||
virtual int getEfficiency(OrderedAIAction * action);
|
||||
virtual int getEfficiency(MTGAbility * ability);
|
||||
virtual bool payTheManaCost(ManaCost * cost, MTGCardInstance * card = NULL,vector<MTGAbility*> gotPayment = vector<MTGAbility*>());
|
||||
virtual int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
|
||||
virtual ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
|
||||
virtual int selectAbility();
|
||||
|
||||
public:
|
||||
enum {
|
||||
INFO_NBCREATURES,
|
||||
INFO_CREATURESPOWER,
|
||||
INFO_CREATURESRANK,
|
||||
INFO_CREATURESTOUGHNESS,
|
||||
INFO_CREATURESATTACKINGPOWER
|
||||
};
|
||||
|
||||
vector<MTGAbility*>gotPayments;
|
||||
|
||||
AIPlayerBaka(GameObserver *observer, string deckFile, string deckfileSmall, string avatarFile, MTGDeck * deck = NULL);
|
||||
@@ -137,4 +130,5 @@ class AIPlayerBaka: public AIPlayer{
|
||||
virtual int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,8 @@ class AIStats;
|
||||
class AIHints;
|
||||
|
||||
|
||||
namespace AI {
|
||||
|
||||
class AIPlayerBakaB: public AIPlayerBaka{
|
||||
protected:
|
||||
int orderBlockers();
|
||||
@@ -18,7 +20,7 @@ protected:
|
||||
int interruptIfICan();
|
||||
int chooseAttackers();
|
||||
int chooseBlockers();
|
||||
int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
|
||||
bool canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
|
||||
int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
|
||||
|
||||
|
||||
@@ -61,6 +63,8 @@ protected:
|
||||
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Wagic, The Homebrew ?! is licensed under the BSD license
|
||||
* See LICENSE in the Folder's root
|
||||
* http://wololo.net/wagic/
|
||||
|
||||
AIPlayerMinMax is the MinMax implementation of the AIPlayer interface
|
||||
*/
|
||||
|
||||
#ifndef _IAPLAYER_MINMAX_H
|
||||
#define _IAPLAYER_MINMAX_H
|
||||
|
||||
#include "AIPlayer.h"
|
||||
#include "config.h"
|
||||
|
||||
namespace AI {
|
||||
|
||||
class AIPlayerMinMax: public AIPlayer{
|
||||
|
||||
protected:
|
||||
void LookAround();
|
||||
|
||||
public:
|
||||
AIPlayerMinMax(GameObserver *observer, string deckFile, string deckFileSmall, string avatarFile, MTGDeck * deck = NULL);
|
||||
virtual ~AIPlayerMinMax();
|
||||
|
||||
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL, MTGCardInstance * Chosencard = NULL, bool checkonly = false) = 0;
|
||||
virtual int affectCombatDamages(CombatStep) = 0;
|
||||
virtual int Act(float dt) = 0;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,8 @@ class MTGCard;
|
||||
class Damage;
|
||||
class WEvent;
|
||||
|
||||
namespace AI {
|
||||
|
||||
class AIStat
|
||||
{
|
||||
public:
|
||||
@@ -49,4 +51,6 @@ public:
|
||||
void Render();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -111,6 +111,7 @@ class GameObserver{
|
||||
void loadPlayer(int playerId, PlayerType playerType = PLAYER_TYPE_HUMAN, int decknb=0, bool premadeDeck=false);
|
||||
virtual void loadPlayer(int playerId, Player* player);
|
||||
|
||||
int getPlayerId(Player* player) {if(player == players[0]) return 1; else if(player == players[1]) return 2; else return 0;};
|
||||
Player * currentPlayer;
|
||||
Player * currentActionPlayer;
|
||||
Player * isInterrupting;
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
std::string GetCurrentDeckStatsFile();
|
||||
virtual bool parseLine(const string& s);
|
||||
friend ostream& operator<<(ostream&, const Player&);
|
||||
friend istream& operator>>(istream&, Player&);
|
||||
friend istream& operator>>(istream&, Player&);
|
||||
bool operator<(Player& aPlayer);
|
||||
bool isDead();
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
int run();
|
||||
};
|
||||
|
||||
class TestSuiteAI:public AIPlayerBaka
|
||||
class TestSuiteAI:public AI::AIPlayerBaka
|
||||
{
|
||||
private:
|
||||
MTGCardInstance * getCard(string action);
|
||||
|
||||
Reference in New Issue
Block a user