Erwan
- small AI improvements for Momir
This commit is contained in:
@@ -47,6 +47,7 @@ class CmpAbilities { // compares Abilities efficiency
|
|||||||
class AIPlayer: public Player{
|
class AIPlayer: public Player{
|
||||||
protected:
|
protected:
|
||||||
MTGCardInstance * nextCardToPlay;
|
MTGCardInstance * nextCardToPlay;
|
||||||
|
int agressivity;
|
||||||
ManaCost * potentialMana;
|
ManaCost * potentialMana;
|
||||||
queue<AIAction *> clickstream;
|
queue<AIAction *> clickstream;
|
||||||
void tapLandsForMana(ManaCost * potentialMana, ManaCost * cost);
|
void tapLandsForMana(ManaCost * potentialMana, ManaCost * cost);
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ MTGAbility * AIMomirPlayer::momirAbility = NULL;
|
|||||||
AIMomirPlayer::AIMomirPlayer(MTGPlayerCards * _deck, char * file, char * avatarFile): AIPlayerBaka(_deck,file, avatarFile){
|
AIMomirPlayer::AIMomirPlayer(MTGPlayerCards * _deck, char * file, char * avatarFile): AIPlayerBaka(_deck,file, avatarFile){
|
||||||
// TODO count min and max number of mana (should probably be part of the gameobserver so that human players don't make mistakes)
|
// TODO count min and max number of mana (should probably be part of the gameobserver so that human players don't make mistakes)
|
||||||
momirAbility = NULL;
|
momirAbility = NULL;
|
||||||
|
agressivity = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AIMomirPlayer::getEfficiency(AIAction * action){
|
int AIMomirPlayer::getEfficiency(AIAction * action){
|
||||||
|
|
||||||
|
|
||||||
int efficiency = AIPlayerBaka::getEfficiency(action);
|
int efficiency = AIPlayerBaka::getEfficiency(action);
|
||||||
if (efficiency < 15) return 0;
|
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
if (g->getCurrentGamePhase() < Constants::MTG_PHASE_FIRSTMAIN) return 0;
|
if (g->getCurrentGamePhase() < Constants::MTG_PHASE_FIRSTMAIN) return 0;
|
||||||
return efficiency;
|
return efficiency;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ AIPlayer::AIPlayer(MTGPlayerCards * _deck, string file): Player(_deck, file){
|
|||||||
potentialMana = NEW ManaCost();
|
potentialMana = NEW ManaCost();
|
||||||
nextCardToPlay = NULL;
|
nextCardToPlay = NULL;
|
||||||
stats = NULL;
|
stats = NULL;
|
||||||
|
agressivity = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
AIPlayer::~AIPlayer(){
|
AIPlayer::~AIPlayer(){
|
||||||
@@ -374,16 +375,21 @@ int AIPlayer::chooseAttackers(){
|
|||||||
int myForce = getCreaturesInfo(this,INFO_CREATURESPOWER,-1,1);
|
int myForce = getCreaturesInfo(this,INFO_CREATURESPOWER,-1,1);
|
||||||
int myCreatures = getCreaturesInfo(this, INFO_NBCREATURES, -1,1);
|
int myCreatures = getCreaturesInfo(this, INFO_NBCREATURES, -1,1);
|
||||||
bool attack = ((myCreatures > opponentCreatures) || (myForce > opponentForce) || (myForce > 2*opponent()->life));
|
bool attack = ((myCreatures > opponentCreatures) || (myForce > opponentForce) || (myForce > 2*opponent()->life));
|
||||||
|
if (agressivity > 80 && !attack && life > opponentForce) {
|
||||||
|
opponentCreatures = getCreaturesInfo(opponent(), INFO_NBCREATURES,-1);
|
||||||
|
opponentForce = getCreaturesInfo(opponent(),INFO_CREATURESPOWER,-1);
|
||||||
|
attack = (myCreatures >= opponentCreatures && myForce > opponentForce) || (myForce > opponentForce) || (myForce > opponent()->life);
|
||||||
|
}
|
||||||
printf("Choose attackers : %i %i %i %i -> %i\n", opponentForce, opponentCreatures, myForce, myCreatures, attack);
|
printf("Choose attackers : %i %i %i %i -> %i\n", opponentForce, opponentCreatures, myForce, myCreatures, attack);
|
||||||
if (attack){
|
if (attack){
|
||||||
CardDescriptor cd;
|
CardDescriptor cd;
|
||||||
cd.init();
|
cd.init();
|
||||||
cd.setType("creature");
|
cd.setType("creature");
|
||||||
MTGCardInstance * card = NULL;
|
MTGCardInstance * card = NULL;
|
||||||
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
MTGAbility * a = g->mLayers->actionLayer()->getAbility(MTGAbility::MTG_ATTACK_RULE);
|
||||||
while((card = cd.nextmatch(game->inPlay, card))){
|
while((card = cd.nextmatch(game->inPlay, card))){
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
g->mLayers->actionLayer()->reactToClick(a,card);
|
||||||
g->cardClick(card);
|
|
||||||
if (g->mLayers->actionLayer()->menuObject) g->mLayers->actionLayer()->doReactTo(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user