mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
- Further work on random trades (experimental, disabled by default.)
This commit is contained in:
@@ -545,12 +545,27 @@ public class AiBlockController {
|
||||
boolean randomTradeIfBehindOnBoard = false;
|
||||
int minRandomTradeChance = 0;
|
||||
int maxRandomTradeChance = 0;
|
||||
int maxCreatDiff = 0;
|
||||
int aiCreatureCount = 0;
|
||||
int oppCreatureCount = 0;
|
||||
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_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);
|
||||
maxCreatDiff = aic.getIntProperty(AiProps.MAX_DIFF_IN_CREATURE_COUNT_TO_TRADE);
|
||||
}
|
||||
|
||||
if (enableRandomTrades) {
|
||||
aiCreatureCount = ComputerUtil.countUsefulCreatures(ai);
|
||||
if (randomTradeIfBehindOnBoard) {
|
||||
aiCreatureCount += maxCreatDiff;
|
||||
}
|
||||
|
||||
if (!attackersLeft.isEmpty()) {
|
||||
oppCreatureCount = ComputerUtil.countUsefulCreatures(attackersLeft.get(0).getController());
|
||||
}
|
||||
}
|
||||
|
||||
for (final Card attacker : attackersLeft) {
|
||||
@@ -586,11 +601,11 @@ public class AiBlockController {
|
||||
int evalAtk = ComputerUtilCard.evaluateCreature(attacker, false, false);
|
||||
int evalBlk = ComputerUtilCard.evaluateCreature(blocker, false, false);
|
||||
boolean powerParityOrHigher = blocker.getNetPower() >= attacker.getNetPower();
|
||||
boolean creatureParityOrHigher = ComputerUtil.countUsefulCreatures(ai) >= ComputerUtil.countUsefulCreatures(attacker.getController());
|
||||
boolean creatureParityOrAllowedDiff = aiCreatureCount >= oppCreatureCount;
|
||||
|
||||
if (evalBlk <= evalAtk
|
||||
if (evalBlk <= evalAtk + 1 // "1" accounts for tapped. Maybe increase to 3 or 5 for higher tolerance?
|
||||
&& powerParityOrHigher
|
||||
&& (creatureParityOrHigher || randomTradeIfBehindOnBoard)
|
||||
&& creatureParityOrAllowedDiff
|
||||
&& MyRandom.percentTrue(chance)) {
|
||||
doTrade = true;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public enum AiProps { /** */
|
||||
ATTACK_INTO_TRADE_WHEN_TAPPED_OUT ("false"), /** */
|
||||
ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK ("false"), /** */
|
||||
RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS ("false"), /** */
|
||||
MAX_DIFF_IN_CREATURE_COUNT_TO_TRADE ("1"), /** */
|
||||
MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK ("20"), /** */
|
||||
MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK ("100"), /** */
|
||||
MIN_SPELL_CMC_TO_COUNTER ("0"),
|
||||
|
||||
@@ -16,10 +16,14 @@ ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
||||
USE_BERSERK_AGGRESSIVELY=false
|
||||
|
||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||
# that the first option serves as a master toggle. If it is disabled, the following related options have no effect.
|
||||
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_WHEN_HAVE_LESS_CREATS=false
|
||||
# If the previous option is enabled, then the next option controls how big of a handicap in creature count the AI
|
||||
# is allowed to have to still decide to trade
|
||||
MAX_DIFF_IN_CREATURE_COUNT_TO_TRADE=1
|
||||
# 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
|
||||
|
||||
@@ -16,10 +16,14 @@ ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
||||
USE_BERSERK_AGGRESSIVELY=false
|
||||
|
||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||
# that the first option serves as a master toggle. If it is disabled, the following related options have no effect.
|
||||
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_WHEN_HAVE_LESS_CREATS=false
|
||||
# If the previous option is enabled, then the next option controls how big of a handicap in creature count the AI
|
||||
# is allowed to have to still decide to trade
|
||||
MAX_DIFF_IN_CREATURE_COUNT_TO_TRADE=1
|
||||
# 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
|
||||
|
||||
@@ -16,10 +16,14 @@ ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
||||
USE_BERSERK_AGGRESSIVELY=true
|
||||
|
||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||
# that the first option serves as a master toggle. If it is disabled, the following related options have no effect.
|
||||
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_WHEN_HAVE_LESS_CREATS=true
|
||||
# If the previous option is enabled, then the next option controls how big of a handicap in creature count the AI
|
||||
# is allowed to have to still decide to trade
|
||||
MAX_DIFF_IN_CREATURE_COUNT_TO_TRADE=1
|
||||
# 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
|
||||
|
||||
@@ -16,10 +16,14 @@ ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=true
|
||||
USE_BERSERK_AGGRESSIVELY=true
|
||||
|
||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker)
|
||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||
# that the first option serves as a master toggle. If it is disabled, the following related options have no effect.
|
||||
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_WHEN_HAVE_LESS_CREATS=false
|
||||
# If the previous option is enabled, then the next option controls how big of a handicap in creature count the AI
|
||||
# is allowed to have to still decide to trade
|
||||
MAX_DIFF_IN_CREATURE_COUNT_TO_TRADE=1
|
||||
# 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