mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Further work on experimental attack/block trade feature (disabled by default).
This commit is contained in:
@@ -590,10 +590,12 @@ public class AiAttackController {
|
||||
|
||||
boolean playAggro = false;
|
||||
int chanceToAttackToTrade = 0;
|
||||
boolean tradeIfTappedOut = false;
|
||||
if (ai.getController().isAI()) {
|
||||
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
|
||||
playAggro = aic.getBooleanProperty(AiProps.PLAY_AGGRO);
|
||||
chanceToAttackToTrade = aic.getIntProperty(AiProps.CHANCE_TO_ATTACK_INTO_TRADE);
|
||||
tradeIfTappedOut = aic.getBooleanProperty(AiProps.ATTACK_INTO_TRADE_WHEN_TAPPED_OUT);
|
||||
}
|
||||
final boolean bAssault = this.doAssault(ai);
|
||||
// TODO: detect Lightmine Field by presence of a card with a specific trigger
|
||||
@@ -921,7 +923,8 @@ public class AiAttackController {
|
||||
} else if (MyRandom.percentTrue(chanceToAttackToTrade) && humanLifeToDamageRatio > 1
|
||||
&& defendingOpponent != null
|
||||
&& ComputerUtil.countUsefulCreatures(ai) > ComputerUtil.countUsefulCreatures(defendingOpponent)
|
||||
&& ai.getLife() > defendingOpponent.getLife()) {
|
||||
&& ai.getLife() > defendingOpponent.getLife()
|
||||
&& (ComputerUtilMana.getAvailableManaEstimate(ai) > 0) || tradeIfTappedOut) {
|
||||
this.aiAggression = 4; // random (chance-based) attack expecting to trade or damage player.
|
||||
} else if (ratioDiff >= 0 && this.attackers.size() > 1) {
|
||||
this.aiAggression = 3; // attack expecting to make good trades or damage player.
|
||||
|
||||
@@ -548,7 +548,7 @@ public class AiBlockController {
|
||||
if (ai.getController().isAI()) {
|
||||
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
|
||||
enableRandomTrades = aic.getBooleanProperty(AiProps.ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK);
|
||||
randomTradeIfBehindOnBoard = aic.getBooleanProperty(AiProps.RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS);
|
||||
randomTradeIfBehindOnBoard = aic.getBooleanProperty(AiProps.RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS);
|
||||
minRandomTradeChance = aic.getIntProperty(AiProps.MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK);
|
||||
maxRandomTradeChance = aic.getIntProperty(AiProps.MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK);
|
||||
}
|
||||
@@ -575,10 +575,10 @@ public class AiBlockController {
|
||||
// Always trade when life in danger
|
||||
doTrade = true;
|
||||
} else if (enableRandomTrades) {
|
||||
// Randomly trade creatures with lower power and [hopefully] worse abilities
|
||||
// Randomly trade creatures with lower power and [hopefully] worse abilities, if enabled in profile
|
||||
int numSteps = ai.getStartingLife() - 5; // e.g. 15 steps between 5 life and 20 life
|
||||
float chanceStep = (maxRandomTradeChance - minRandomTradeChance) / numSteps;
|
||||
int chance = (int)Math.max(minRandomTradeChance, (maxRandomTradeChance - (Math.abs(5 - ai.getLife()) * chanceStep)));
|
||||
int chance = (int)Math.max(minRandomTradeChance, (maxRandomTradeChance - (Math.max(5, ai.getLife() - 5)) * chanceStep));
|
||||
if (chance > maxRandomTradeChance) {
|
||||
chance = maxRandomTradeChance;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ public enum AiProps { /** */
|
||||
RESERVE_MANA_FOR_MAIN2_CHANCE ("0"), /** */
|
||||
PLAY_AGGRO ("false"),
|
||||
CHANCE_TO_ATTACK_INTO_TRADE ("100"), /** */
|
||||
ATTACK_INTO_TRADE_WHEN_TAPPED_OUT ("false"), /** */
|
||||
ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK ("false"), /** */
|
||||
RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS ("false"), /** */
|
||||
RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS ("false"), /** */
|
||||
MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK ("20"), /** */
|
||||
MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK ("100"), /** */
|
||||
MIN_SPELL_CMC_TO_COUNTER ("0"),
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
MULLIGAN_THRESHOLD=4
|
||||
|
||||
# Aggro preferences (enabling these will generally make the AI attack more aggressively into potential trades)
|
||||
# If the following option is enabled, the AI will generally play aggressively, seeking trades on offense when possible
|
||||
# (the following two parameters will then be ignored)
|
||||
PLAY_AGGRO=false
|
||||
# The chance to attack aggressively into a potential trade (works even if not playing all-out aggro, e.g. PLAY_AGGRO disabled,
|
||||
# but only in more favorable conditions in that case - when ahead in life count and in parity or ahead in creature count)
|
||||
CHANCE_TO_ATTACK_INTO_TRADE=0
|
||||
# When enabled, the AI will attack into trading options when it's tapped out (note that this flag is ignored if PLAY_AGGRO
|
||||
# is globally enabled). If disabled, the non-aggro AI will only attack into trades when it has mana open, thus having a chance
|
||||
# to "bluff" (or use, if available) combat tricks at the same time.
|
||||
ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
||||
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
||||
USE_BERSERK_AGGRESSIVELY=false
|
||||
|
||||
@@ -13,7 +19,7 @@ USE_BERSERK_AGGRESSIVELY=false
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK=false
|
||||
# If enabled, the AI will consider trade blocking even if its creature count is lower than the opponent's
|
||||
RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS=false
|
||||
RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS=false
|
||||
# Min and max chance to randomly aggressively trade when blocking (note that it will become 100 if the AI is in danger)
|
||||
MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=20
|
||||
MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=65
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
MULLIGAN_THRESHOLD=4
|
||||
|
||||
# Aggro preferences (enabling these will generally make the AI attack more aggressively into potential trades)
|
||||
# If the following option is enabled, the AI will generally play aggressively, seeking trades on offense when possible
|
||||
# (the following two parameters will then be ignored)
|
||||
PLAY_AGGRO=false
|
||||
# The chance to attack aggressively into a potential trade (works even if not playing all-out aggro, e.g. PLAY_AGGRO disabled,
|
||||
# but only in more favorable conditions in that case - when ahead in life count and in parity or ahead in creature count)
|
||||
CHANCE_TO_ATTACK_INTO_TRADE=0
|
||||
# When enabled, the AI will attack into trading options when it's tapped out (note that this flag is ignored if PLAY_AGGRO
|
||||
# is globally enabled). If disabled, the non-aggro AI will only attack into trades when it has mana open, thus having a chance
|
||||
# to "bluff" (or use, if available) combat tricks at the same time.
|
||||
ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
||||
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
||||
USE_BERSERK_AGGRESSIVELY=false
|
||||
|
||||
@@ -13,7 +19,7 @@ USE_BERSERK_AGGRESSIVELY=false
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK=false
|
||||
# If enabled, the AI will consider trade blocking even if its creature count is lower than the opponent's
|
||||
RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS=false
|
||||
RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS=false
|
||||
# Min and max chance to randomly aggressively trade when blocking (note that it will become 100 if the AI is in danger)
|
||||
MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=20
|
||||
MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=65
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
MULLIGAN_THRESHOLD=4
|
||||
|
||||
# Aggro preferences (enabling these will generally make the AI attack more aggressively into potential trades)
|
||||
# If the following option is enabled, the AI will generally play aggressively, seeking trades on offense when possible
|
||||
# (the following two parameters will then be ignored)
|
||||
PLAY_AGGRO=false
|
||||
# The chance to attack aggressively into a potential trade (works even if not playing all-out aggro, e.g. PLAY_AGGRO disabled,
|
||||
# but only in more favorable conditions in that case - when ahead in life count and in parity or ahead in creature count)
|
||||
CHANCE_TO_ATTACK_INTO_TRADE=20
|
||||
# When enabled, the AI will attack into trading options when it's tapped out (note that this flag is ignored if PLAY_AGGRO
|
||||
# is globally enabled). If disabled, the non-aggro AI will only attack into trades when it has mana open, thus having a chance
|
||||
# to "bluff" (or use, if available) combat tricks at the same time.
|
||||
ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
||||
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
||||
USE_BERSERK_AGGRESSIVELY=true
|
||||
|
||||
@@ -13,7 +19,7 @@ USE_BERSERK_AGGRESSIVELY=true
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK=true
|
||||
# If enabled, the AI will consider trade blocking even if its creature count is lower than the opponent's
|
||||
RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS=true
|
||||
RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS=true
|
||||
# Min and max chance to randomly aggressively trade when blocking (note that it will become 100 if the AI is in danger)
|
||||
MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=20
|
||||
MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=65
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
MULLIGAN_THRESHOLD=3
|
||||
|
||||
# Aggro preferences (enabling these will generally make the AI attack more aggressively)
|
||||
# If the following option is enabled, the AI will generally play aggressively, seeking trades on offense when possible
|
||||
# (the following two parameters will then be ignored)
|
||||
PLAY_AGGRO=true
|
||||
# The chance to attack aggressively into a potential trade (works even if not playing all-out aggro, e.g. PLAY_AGGRO disabled,
|
||||
# but only in more favorable conditions in that case - when ahead in life count and in parity or ahead in creature count)
|
||||
CHANCE_TO_ATTACK_INTO_TRADE=100
|
||||
# When enabled, the AI will attack into trading options when it's tapped out (note that this flag is ignored if PLAY_AGGRO
|
||||
# is globally enabled). If disabled, the non-aggro AI will only attack into trades when it has mana open, thus having a chance
|
||||
# to "bluff" (or use, if available) combat tricks at the same time.
|
||||
ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=true
|
||||
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
||||
USE_BERSERK_AGGRESSIVELY=true
|
||||
|
||||
@@ -13,7 +19,7 @@ USE_BERSERK_AGGRESSIVELY=true
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK=false
|
||||
# If enabled, the AI will consider trade blocking even if its creature count is lower than the opponent's
|
||||
RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS=false
|
||||
RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS=false
|
||||
# Min and max chance to randomly aggressively trade when blocking (note that it will become 100 if the AI is in danger)
|
||||
MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=20
|
||||
MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK=65
|
||||
|
||||
Reference in New Issue
Block a user