Erwan
-attempt at issue 81. It will do for now
This commit is contained in:
@@ -29,6 +29,7 @@ class ManaCost{
|
|||||||
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
|
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
|
||||||
virtual void init();
|
virtual void init();
|
||||||
void x();
|
void x();
|
||||||
|
int hasX();
|
||||||
ManaCost(int _cost[], int nb_elems = 1);
|
ManaCost(int _cost[], int nb_elems = 1);
|
||||||
ManaCost();
|
ManaCost();
|
||||||
~ManaCost();
|
~ManaCost();
|
||||||
|
|||||||
@@ -592,26 +592,36 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * potentialMana, const c
|
|||||||
if (card->hasType("land") && !this->canPutLandsIntoPlay) continue;
|
if (card->hasType("land") && !this->canPutLandsIntoPlay) continue;
|
||||||
if (card->has(Constants::LEGENDARY) && game->inPlay->findByName(card->name)) continue;
|
if (card->has(Constants::LEGENDARY) && game->inPlay->findByName(card->name)) continue;
|
||||||
int currentCost = card->getManaCost()->getConvertedCost();
|
int currentCost = card->getManaCost()->getConvertedCost();
|
||||||
if (currentCost > maxCost && potentialMana->canAfford(card->getManaCost())){
|
int hasX = card->getManaCost()->hasX();
|
||||||
|
if ((currentCost > maxCost || hasX) && potentialMana->canAfford(card->getManaCost())){
|
||||||
TargetChooserFactory * tcf = NEW TargetChooserFactory();
|
TargetChooserFactory * tcf = NEW TargetChooserFactory();
|
||||||
TargetChooser * tc = tcf->createTargetChooser(card);
|
TargetChooser * tc = tcf->createTargetChooser(card);
|
||||||
delete tcf;
|
delete tcf;
|
||||||
|
int shouldPlayPercentage = 10;
|
||||||
if (tc){
|
if (tc){
|
||||||
int hasTarget = (chooseTarget(tc));
|
int hasTarget = (chooseTarget(tc));
|
||||||
delete tc;
|
delete tc;
|
||||||
if (!hasTarget)continue;
|
if (!hasTarget)continue;
|
||||||
|
shouldPlayPercentage = 90;
|
||||||
}else{
|
}else{
|
||||||
int shouldPlayPercentage = 10;
|
|
||||||
int shouldPlay = effectBadOrGood(card);
|
int shouldPlay = effectBadOrGood(card);
|
||||||
if (shouldPlay == BAKA_EFFECT_GOOD){
|
if (shouldPlay == BAKA_EFFECT_GOOD){
|
||||||
shouldPlayPercentage = 90;
|
shouldPlayPercentage = 90;
|
||||||
}else if(BAKA_EFFECT_DONTKNOW == shouldPlay){
|
}else if(BAKA_EFFECT_DONTKNOW == shouldPlay){
|
||||||
shouldPlayPercentage = 80;
|
shouldPlayPercentage = 80;
|
||||||
}
|
}
|
||||||
if (rand() % 100 > shouldPlayPercentage) continue;
|
|
||||||
}
|
}
|
||||||
|
//Reduce the chances of playing a spell with X cost if available mana is low
|
||||||
|
if (hasX){
|
||||||
|
int xDiff = potentialMana->getConvertedCost() - currentCost;
|
||||||
|
if (xDiff < 0) xDiff = 0;
|
||||||
|
shouldPlayPercentage = shouldPlayPercentage - ((shouldPlayPercentage * 1.9) / (1 + xDiff));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rand() % 100 > shouldPlayPercentage) continue;
|
||||||
nextCardToPlay = card;
|
nextCardToPlay = card;
|
||||||
maxCost = currentCost;
|
maxCost = currentCost;
|
||||||
|
if(hasX) maxCost = potentialMana->getConvertedCost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nextCardToPlay;
|
return nextCardToPlay;
|
||||||
@@ -671,8 +681,8 @@ int AIPlayerBaka::computeActions(){
|
|||||||
//Let's Try an enchantment maybe ?
|
//Let's Try an enchantment maybe ?
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "enchantment");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "enchantment");
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "artifact");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "artifact");
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
|
||||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "sorcery");
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "sorcery");
|
||||||
|
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
||||||
if (nextCardToPlay){
|
if (nextCardToPlay){
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
char buffe[4096];
|
char buffe[4096];
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ void ManaCost::x(){
|
|||||||
cost[Constants::MTG_NB_COLORS] = 1;
|
cost[Constants::MTG_NB_COLORS] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ManaCost::hasX(){
|
||||||
|
return cost[Constants::MTG_NB_COLORS];
|
||||||
|
}
|
||||||
|
|
||||||
void ManaCost::init(){
|
void ManaCost::init(){
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<= Constants::MTG_NB_COLORS; i++){
|
for (i=0; i<= Constants::MTG_NB_COLORS; i++){
|
||||||
@@ -379,7 +383,7 @@ ManaCost * ManaCost::Diff(ManaCost * _cost){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Cost X
|
//Cost X
|
||||||
if (_cost->getCost(Constants::MTG_NB_COLORS)){
|
if (_cost->hasX()){
|
||||||
diff[Constants::MTG_NB_COLORS * 2 + 1] = 0;
|
diff[Constants::MTG_NB_COLORS * 2 + 1] = 0;
|
||||||
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
|
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
|
||||||
if (diff[i*2 + 1] > 0){
|
if (diff[i*2 + 1] > 0){
|
||||||
|
|||||||
Reference in New Issue
Block a user