- Tweak spell prediction when deciding whether to move equipment or not.

- Enable spell prediction (works for AttachAi only at the moment).
- The Default AI profile will only move equipment from one creature to another if the one it's currently attached to is useless, but will consider it a priority task to move equipment away from useless creatures.
- The Reckless AI profile will always move equipment from worse creatures to better ones but will prioritize getting as many threats and other permanents out before moving creatures around (currently - even if the creature the equipment is attached to was rendered useless).
This commit is contained in:
Agetian
2014-09-20 08:01:58 +00:00
parent 2abcc7c951
commit 5549604d0d
4 changed files with 13 additions and 6 deletions

View File

@@ -31,6 +31,7 @@ public enum AiProps { /** */
PLANAR_DIE_ROLL_HESITATION_CHANCE ("10"), PLANAR_DIE_ROLL_HESITATION_CHANCE ("10"),
CHEAT_WITH_MANA_ON_SHUFFLE ("false"), CHEAT_WITH_MANA_ON_SHUFFLE ("false"),
MOVE_EQUIPMENT_TO_BETTER_CREATURES ("from_useless_only"), MOVE_EQUIPMENT_TO_BETTER_CREATURES ("from_useless_only"),
PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS ("false"),
PREDICT_SPELLS_FOR_MAIN2 ("true"), /** */ PREDICT_SPELLS_FOR_MAIN2 ("true"), /** */
RESERVE_MANA_FOR_MAIN2_CHANCE ("0"); /** */ RESERVE_MANA_FOR_MAIN2_CHANCE ("0"); /** */

View File

@@ -1026,19 +1026,23 @@ public class AttachAi extends SpellAbilityAi {
return null; return null;
} }
boolean uselessCreature = isUselessCreature(aiPlayer, attachSource.getEquippingCard());
if (aic.getProperty(AiProps.MOVE_EQUIPMENT_TO_BETTER_CREATURES).equals("never")) { if (aic.getProperty(AiProps.MOVE_EQUIPMENT_TO_BETTER_CREATURES).equals("never")) {
// Do not equip other creatures if the AI profile does not allow moving equipment around // Do not equip other creatures if the AI profile does not allow moving equipment around
return null; return null;
} else if (aic.getProperty(AiProps.MOVE_EQUIPMENT_TO_BETTER_CREATURES).equals("from_useless_only")) { } else if (aic.getProperty(AiProps.MOVE_EQUIPMENT_TO_BETTER_CREATURES).equals("from_useless_only")) {
// Do not equip other creatures if the AI profile only allows moving equipment from useless creatures // Do not equip other creatures if the AI profile only allows moving equipment from useless creatures
// and the equipped creature is still useful (not non-untapping+tapped and not set to can't attack/block) // and the equipped creature is still useful (not non-untapping+tapped and not set to can't attack/block)
if (!isUselessCreature(aiPlayer, attachSource.getEquippingCard())) { if (!uselessCreature) {
return null; return null;
} }
} }
// make sure to prioritize casting spells in main 2 (creatures, other equipment, etc.) rather than moving equipment around // make sure to prioritize casting spells in main 2 (creatures, other equipment, etc.) rather than moving equipment around
if (aic.getCardMemory().isMemorySetEmpty(AiCardMemory.MemorySet.HELD_MANA_SOURCES)) { boolean decideMoveFromUseless = uselessCreature && aic.getBooleanProperty(AiProps.PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS);
if (!decideMoveFromUseless && aic.getCardMemory().isMemorySetEmpty(AiCardMemory.MemorySet.HELD_MANA_SOURCES)) {
SpellAbility futureSpell = aic.predictSpellToCastInMain2(ApiType.Attach); SpellAbility futureSpell = aic.predictSpellToCastInMain2(ApiType.Attach);
if (futureSpell != null && futureSpell.getHostCard() != null) { if (futureSpell != null && futureSpell.getHostCard() != null) {
aic.reserveManaSourcesForMain2(futureSpell); aic.reserveManaSourcesForMain2(futureSpell);

View File

@@ -5,6 +5,7 @@ DEFAULT_PLANAR_DIE_ROLL_CHANCE=50
MULLIGAN_THRESHOLD=5 MULLIGAN_THRESHOLD=5
PLANAR_DIE_ROLL_HESITATION_CHANCE=10 PLANAR_DIE_ROLL_HESITATION_CHANCE=10
MOVE_EQUIPMENT_TO_BETTER_CREATURES=from_useless_only MOVE_EQUIPMENT_TO_BETTER_CREATURES=from_useless_only
PREDICT_SPELLS_FOR_MAIN2=false PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=true
RESERVE_MANA_FOR_MAIN2_CHANCE=0 PREDICT_SPELLS_FOR_MAIN2=true
RESERVE_MANA_FOR_MAIN2_CHANCE=100

View File

@@ -5,5 +5,6 @@ DEFAULT_PLANAR_DIE_ROLL_CHANCE=100
MULLIGAN_THRESHOLD=3 MULLIGAN_THRESHOLD=3
PLANAR_DIE_ROLL_HESITATION_CHANCE=0 PLANAR_DIE_ROLL_HESITATION_CHANCE=0
MOVE_EQUIPMENT_TO_BETTER_CREATURES=always MOVE_EQUIPMENT_TO_BETTER_CREATURES=always
PREDICT_SPELLS_FOR_MAIN2=false PRIORITIZE_MOVE_EQUIPMENT_IF_USELESS=false
RESERVE_MANA_FOR_MAIN2_CHANCE=0 PREDICT_SPELLS_FOR_MAIN2=true
RESERVE_MANA_FOR_MAIN2_CHANCE=100