- Improve AI logic for Bound by Moonsilver.

This commit is contained in:
Agetian
2020-07-20 08:03:10 +03:00
parent aafbdd1a9c
commit 62d3c4457b
7 changed files with 34 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ public enum AiProps { /** */
MOVE_EQUIPMENT_TO_BETTER_CREATURES ("from_useless_only"), MOVE_EQUIPMENT_TO_BETTER_CREATURES ("from_useless_only"),
MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD ("60"), MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD ("60"),
PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS ("true"), PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS ("true"),
SAC_TO_REATTACH_TARGET_EVAL_THRESHOLD ("400"),
PREDICT_SPELLS_FOR_MAIN2 ("true"), /** */ PREDICT_SPELLS_FOR_MAIN2 ("true"), /** */
RESERVE_MANA_FOR_MAIN2_CHANCE ("0"), /** */ RESERVE_MANA_FOR_MAIN2_CHANCE ("0"), /** */
PLAY_AGGRO ("false"), PLAY_AGGRO ("false"),

View File

@@ -838,7 +838,7 @@ public class AttachAi extends SpellAbilityAi {
* @return the card * @return the card
*/ */
private static Card attachAICursePreference(final SpellAbility sa, final List<Card> list, final boolean mandatory, private static Card attachAICursePreference(final SpellAbility sa, final List<Card> list, final boolean mandatory,
final Card attachSource) { final Card attachSource, final Player ai) {
// AI For choosing a Card to Curse of. // AI For choosing a Card to Curse of.
// TODO Figure out some way to combine The "gathering of data" from // TODO Figure out some way to combine The "gathering of data" from
@@ -930,6 +930,24 @@ public class AttachAi extends SpellAbilityAi {
); );
} }
// If this is already attached and there's a sac cost, make sure we attach to something that's
// seriously better than whatever the attachment is currently attached to (e.g. Bound by Moonsilver)
if (sa.getHostCard().getAttachedTo() != null && sa.getHostCard().getAttachedTo().isCreature()
&& sa.getPayCosts() != null && sa.getPayCosts().hasSpecificCostType(CostSacrifice.class)) {
final int oldEvalRating = ComputerUtilCard.evaluateCreature(sa.getHostCard().getAttachedTo());
final int threshold = ai.isAI() ? ((PlayerControllerAi)ai.getController()).getAi().getIntProperty(AiProps.SAC_TO_REATTACH_TARGET_EVAL_THRESHOLD) : Integer.MAX_VALUE;
prefList = CardLists.filter(prefList, new Predicate<Card>() {
@Override
public boolean apply(Card card) {
if (!card.isCreature()) {
return false;
}
return ComputerUtilCard.evaluateCreature(card) >= oldEvalRating + threshold;
}
});
}
c = ComputerUtilCard.getBestAI(prefList); c = ComputerUtilCard.getBestAI(prefList);
if (c == null) { if (c == null) {
@@ -1455,7 +1473,7 @@ public class AttachAi extends SpellAbilityAi {
if ("GainControl".equals(logic)) { if ("GainControl".equals(logic)) {
c = attachAIControlPreference(sa, prefList, mandatory, attachSource); c = attachAIControlPreference(sa, prefList, mandatory, attachSource);
} else if ("Curse".equals(logic)) { } else if ("Curse".equals(logic)) {
c = attachAICursePreference(sa, prefList, mandatory, attachSource); c = attachAICursePreference(sa, prefList, mandatory, attachSource, ai);
} else if ("Pump".equals(logic)) { } else if ("Pump".equals(logic)) {
c = attachAIPumpPreference(ai, sa, prefList, mandatory, attachSource); c = attachAIPumpPreference(ai, sa, prefList, mandatory, attachSource);
} else if ("Curiosity".equals(logic)) { } else if ("Curiosity".equals(logic)) {

View File

@@ -100,6 +100,9 @@ PLANAR_DIE_ROLL_HESITATION_CHANCE=10
MOVE_EQUIPMENT_TO_BETTER_CREATURES=from_useless_only MOVE_EQUIPMENT_TO_BETTER_CREATURES=from_useless_only
MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=60 MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=60
PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=true PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=true
# If there's a sacrifice cost to reattach an aura/equipment to another target creature, how big of an evaluation difference
# should there be between the old target and the new one for the AI to decide to proceed with it.
SAC_TO_REATTACH_TARGET_EVAL_THRESHOLD=500
# Currently disabled # Currently disabled
PREDICT_SPELLS_FOR_MAIN2=true PREDICT_SPELLS_FOR_MAIN2=true

View File

@@ -100,6 +100,9 @@ PLANAR_DIE_ROLL_HESITATION_CHANCE=10
MOVE_EQUIPMENT_TO_BETTER_CREATURES=from_useless_only MOVE_EQUIPMENT_TO_BETTER_CREATURES=from_useless_only
MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=60 MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=60
PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=true PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=true
# If there's a sacrifice cost to reattach an aura/equipment to another target creature, how big of an evaluation difference
# should there be between the old target and the new one for the AI to decide to proceed with it.
SAC_TO_REATTACH_TARGET_EVAL_THRESHOLD=400
# Currently disabled # Currently disabled
PREDICT_SPELLS_FOR_MAIN2=true PREDICT_SPELLS_FOR_MAIN2=true

View File

@@ -100,6 +100,9 @@ PLANAR_DIE_ROLL_HESITATION_CHANCE=10
MOVE_EQUIPMENT_TO_BETTER_CREATURES=always MOVE_EQUIPMENT_TO_BETTER_CREATURES=always
MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=60 MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=60
PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=true PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=true
# If there's a sacrifice cost to reattach an aura/equipment to another target creature, how big of an evaluation difference
# should there be between the old target and the new one for the AI to decide to proceed with it.
SAC_TO_REATTACH_TARGET_EVAL_THRESHOLD=350
# Currently disabled # Currently disabled
PREDICT_SPELLS_FOR_MAIN2=true PREDICT_SPELLS_FOR_MAIN2=true

View File

@@ -100,6 +100,9 @@ PLANAR_DIE_ROLL_HESITATION_CHANCE=0
MOVE_EQUIPMENT_TO_BETTER_CREATURES=always MOVE_EQUIPMENT_TO_BETTER_CREATURES=always
MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=50 MOVE_EQUIPMENT_CREATURE_EVAL_THRESHOLD=50
PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=false PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=false
# If there's a sacrifice cost to reattach an aura/equipment to another target creature, how big of an evaluation difference
# should there be between the old target and the new one for the AI to decide to proceed with it.
SAC_TO_REATTACH_TARGET_EVAL_THRESHOLD=300
# Currently disabled # Currently disabled
PREDICT_SPELLS_FOR_MAIN2=true PREDICT_SPELLS_FOR_MAIN2=true

View File

@@ -5,5 +5,6 @@ K:Enchant creature
A:SP$ Attach | Cost$ 2 W | ValidTgts$ Creature | AILogic$ Curse A:SP$ Attach | Cost$ 2 W | ValidTgts$ Creature | AILogic$ Curse
S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddHiddenKeyword$ CARDNAME can't attack or block. & CARDNAME can't transform | Description$ Enchanted creature can't attack, block, or transform. S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddHiddenKeyword$ CARDNAME can't attack or block. & CARDNAME can't transform | Description$ Enchanted creature can't attack, block, or transform.
A:AB$ Attach | Cost$ Sac<1/Permanent.Other/another permanent> | ValidTgts$ Creature | TgtPrompt$ Select target creature | AILogic$ Curse | SorcerySpeed$ True | ActivationLimit$ 1 | SpellDescription$ Attach CARDNAME to target creature. Activate this ability only any time you could cast a sorcery and only once each turn. A:AB$ Attach | Cost$ Sac<1/Permanent.Other/another permanent> | ValidTgts$ Creature | TgtPrompt$ Select target creature | AILogic$ Curse | SorcerySpeed$ True | ActivationLimit$ 1 | SpellDescription$ Attach CARDNAME to target creature. Activate this ability only any time you could cast a sorcery and only once each turn.
SVar:AIPreference:SacCost$Card.token,Permanent.nonLand+cmcLE2,Land.Basic
SVar:Picture:http://www.wizards.com/global/images/magic/general/bound_by_moonsilver.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/bound_by_moonsilver.jpg
Oracle:Enchant creature\nEnchanted creature can't attack, block, or transform.\nSacrifice another permanent: Attach Bound by Moonsilver to target creature. Activate this ability only any time you could cast a sorcery and only once each turn. Oracle:Enchant creature\nEnchanted creature can't attack, block, or transform.\nSacrifice another permanent: Attach Bound by Moonsilver to target creature. Activate this ability only any time you could cast a sorcery and only once each turn.