- Improvements to Counter AI.

This commit is contained in:
Agetian
2017-09-14 06:18:05 +00:00
parent cc7ce6bae9
commit 05a9d457aa
6 changed files with 55 additions and 13 deletions

View File

@@ -53,11 +53,16 @@ public enum AiProps { /** */
CHANCE_TO_TRADE_TO_SAVE_PLANESWALKER ("70"), /** */
CHANCE_TO_TRADE_DOWN_TO_SAVE_PLANESWALKER ("0"), /** */
THRESHOLD_CHUMP_TO_SAVE_PLANESWALKER ("-1"), /** */
MIN_SPELL_CMC_TO_COUNTER ("0"),
MIN_SPELL_CMC_TO_COUNTER ("0"), /** */
CHANCE_TO_COUNTER_CMC_1 ("50"), /** */
CHANCE_TO_COUNTER_CMC_2 ("75"), /** */
CHANCE_TO_COUNTER_CMC_3 ("100"), /** */
ALWAYS_COUNTER_OTHER_COUNTERSPELLS ("true"), /** */
ALWAYS_COUNTER_DAMAGE_SPELLS ("true"), /** */
ALWAYS_COUNTER_CMC_0_MANA_MAKING_PERMS ("true"), /** */
ALWAYS_COUNTER_REMOVAL_SPELLS ("true"), /** */
ALWAYS_COUNTER_PUMP_SPELLS ("true"), /** */
ALWAYS_COUNTER_AURAS ("true"), /** */
ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS (""), /** */
ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS ("false"), /** */
PRIORITY_REDUCTION_FOR_STORM_SPELLS ("0"), /** */

View File

@@ -144,14 +144,31 @@ public class CounterAi extends SpellAbilityAi {
boolean ctrCmc0ManaPerms = aic.getBooleanProperty(AiProps.ALWAYS_COUNTER_CMC_0_MANA_MAKING_PERMS);
boolean ctrDamageSpells = aic.getBooleanProperty(AiProps.ALWAYS_COUNTER_DAMAGE_SPELLS);
boolean ctrRemovalSpells = aic.getBooleanProperty(AiProps.ALWAYS_COUNTER_REMOVAL_SPELLS);
boolean ctrPumpSpells = aic.getBooleanProperty(AiProps.ALWAYS_COUNTER_PUMP_SPELLS);
boolean ctrAuraSpells = aic.getBooleanProperty(AiProps.ALWAYS_COUNTER_AURAS);
boolean ctrOtherCounters = aic.getBooleanProperty(AiProps.ALWAYS_COUNTER_OTHER_COUNTERSPELLS);
int ctrChanceCMC1 = aic.getIntProperty(AiProps.CHANCE_TO_COUNTER_CMC_1);
int ctrChanceCMC2 = aic.getIntProperty(AiProps.CHANCE_TO_COUNTER_CMC_2);
int ctrChanceCMC3 = aic.getIntProperty(AiProps.CHANCE_TO_COUNTER_CMC_3);
String ctrNamed = aic.getProperty(AiProps.ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS);
boolean dontCounter = false;
if (tgtCMC == 1 && !MyRandom.percentTrue(ctrChanceCMC1)) {
dontCounter = true;
} else if (tgtCMC == 2 && !MyRandom.percentTrue(ctrChanceCMC2)) {
dontCounter = true;
} else if (tgtCMC == 3 && !MyRandom.percentTrue(ctrChanceCMC3)) {
dontCounter = true;
}
if (tgtSA != null && tgtCMC < aic.getIntProperty(AiProps.MIN_SPELL_CMC_TO_COUNTER)) {
boolean dontCounter = true;
dontCounter = true;
Card tgtSource = tgtSA.getHostCard();
if ((tgtSource != null && tgtCMC == 0 && tgtSource.isPermanent() && !tgtSource.getManaAbilities().isEmpty() && ctrCmc0ManaPerms)
|| (tgtSA.getApi() == ApiType.DealDamage || tgtSA.getApi() == ApiType.LoseLife || tgtSA.getApi() == ApiType.DamageAll && ctrDamageSpells)
|| (tgtSA.getApi() == ApiType.Counter && ctrOtherCounters)
|| ((tgtSA.getApi() == ApiType.Pump || tgtSA.getApi() == ApiType.PumpAll) && ctrPumpSpells)
|| (tgtSA.getApi() == ApiType.Attach && ctrAuraSpells)
|| (tgtSA.getApi() == ApiType.Destroy || tgtSA.getApi() == ApiType.DestroyAll || tgtSA.getApi() == ApiType.Sacrifice
|| tgtSA.getApi() == ApiType.SacrificeAll && ctrRemovalSpells)) {
dontCounter = false;
@@ -165,7 +182,7 @@ public class CounterAi extends SpellAbilityAi {
}
}
// should not refrain from countering a CMC X spell if that's the only CMC
// should not refrain from countering a CMC X spell if that's the only CMC
// counterable with that particular counterspell type (e.g. Mental Misstep vs. CMC 1 spells)
if (sa.getParamOrDefault("ValidTgts", "").startsWith("Card.cmcEQ")) {
int validTgtCMC = AbilityUtils.calculateAmount(source, sa.getParam("ValidTgts").substring(10), sa);
@@ -173,10 +190,10 @@ public class CounterAi extends SpellAbilityAi {
dontCounter = false;
}
}
}
if (dontCounter) {
return false;
}
if (dontCounter) {
return false;
}
return toReturn;

View File

@@ -80,12 +80,17 @@ RESERVE_MANA_FOR_MAIN2_CHANCE=100
# If enabled, the AI will target artifacts and non-aura enchantments with removal aggressively
ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS=true
# Counterspell timings
# Permission timings
MIN_SPELL_CMC_TO_COUNTER=2
CHANCE_TO_COUNTER_CMC_1=0
CHANCE_TO_COUNTER_CMC_2=50
CHANCE_TO_COUNTER_CMC_3=100
ALWAYS_COUNTER_OTHER_COUNTERSPELLS=true
ALWAYS_COUNTER_DAMAGE_SPELLS=true
ALWAYS_COUNTER_CMC_0_MANA_MAKING_PERMS=true
ALWAYS_COUNTER_REMOVAL_SPELLS=true
ALWAYS_COUNTER_PUMP_SPELLS=false
ALWAYS_COUNTER_AURAS=true
ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None
# Storm spell logic

View File

@@ -80,12 +80,17 @@ RESERVE_MANA_FOR_MAIN2_CHANCE=100
# If enabled, the AI will target artifacts and non-aura enchantments with removal aggressively
ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS=true
# Counterspell timings
# Permission timings
MIN_SPELL_CMC_TO_COUNTER=0
CHANCE_TO_COUNTER_CMC_1=30
CHANCE_TO_COUNTER_CMC_2=75
CHANCE_TO_COUNTER_CMC_3=100
ALWAYS_COUNTER_OTHER_COUNTERSPELLS=true
ALWAYS_COUNTER_DAMAGE_SPELLS=true
ALWAYS_COUNTER_CMC_0_MANA_MAKING_PERMS=true
ALWAYS_COUNTER_REMOVAL_SPELLS=true
ALWAYS_COUNTER_PUMP_SPELLS=true
ALWAYS_COUNTER_AURAS=true
ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None
# Storm spell logic

View File

@@ -80,12 +80,17 @@ RESERVE_MANA_FOR_MAIN2_CHANCE=100
# If enabled, the AI will target artifacts and non-aura enchantments with removal aggressively
ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS=true
# Counterspell timings
# Permission timings
MIN_SPELL_CMC_TO_COUNTER=2
CHANCE_TO_COUNTER_CMC_1=30
CHANCE_TO_COUNTER_CMC_2=75
CHANCE_TO_COUNTER_CMC_3=100
ALWAYS_COUNTER_OTHER_COUNTERSPELLS=true
ALWAYS_COUNTER_DAMAGE_SPELLS=true
ALWAYS_COUNTER_CMC_0_MANA_MAKING_PERMS=true
ALWAYS_COUNTER_REMOVAL_SPELLS=true
ALWAYS_COUNTER_PUMP_SPELLS=true
ALWAYS_COUNTER_AURAS=true
ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None
# Storm spell logic

View File

@@ -80,12 +80,17 @@ RESERVE_MANA_FOR_MAIN2_CHANCE=100
# If enabled, the AI will target artifacts and non-aura enchantments with removal aggressively
ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS=true
# Counterspell timings
# Permission timings
MIN_SPELL_CMC_TO_COUNTER=0
CHANCE_TO_COUNTER_CMC_1=80
CHANCE_TO_COUNTER_CMC_2=100
CHANCE_TO_COUNTER_CMC_3=100
ALWAYS_COUNTER_OTHER_COUNTERSPELLS=true
ALWAYS_COUNTER_DAMAGE_SPELLS=true
ALWAYS_COUNTER_CMC_0_MANA_MAKING_PERMS=true
ALWAYS_COUNTER_REMOVAL_SPELLS=true
ALWAYS_COUNTER_PUMP_SPELLS=true
ALWAYS_COUNTER_AURAS=true
ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None
# Storm spell logic