- At least for now, added an AI profile property RESERVE_MANA_FOR_MAIN2_CHANCE that indicates a chance that the AI would want to reserve mana for a main 2 phase spell. Currently set to 0 for all profiles (the AI will not reserve mana).

- The AI will obey mana reservations either if the spell ability is explicitly marked as low priority with SVar LowPriorityAI or, if it's not marked as low priority, depending on the random chance as specified in RESERVE_MANA_FOR_MAIN2_CHANCE.
This commit is contained in:
Agetian
2014-09-18 11:47:45 +00:00
parent 50553802e7
commit cf70a969b1
4 changed files with 17 additions and 5 deletions

View File

@@ -30,7 +30,8 @@ public enum AiProps { /** */
MULLIGAN_THRESHOLD ("5"), /** */
PLANAR_DIE_ROLL_HESITATION_CHANCE ("10"),
CHEAT_WITH_MANA_ON_SHUFFLE ("false"),
MOVE_EQUIPMENT_TO_BETTER_CREATURES ("always"); /** */
MOVE_EQUIPMENT_TO_BETTER_CREATURES ("from_useless_only"),
RESERVE_MANA_FOR_MAIN2_CHANCE ("0"); /** */
private final String strDefaultVal;

View File

@@ -30,6 +30,7 @@ import forge.game.spellability.AbilityManaPart;
import forge.game.spellability.AbilitySub;
import forge.game.spellability.SpellAbility;
import forge.game.zone.ZoneType;
import forge.util.MyRandom;
import forge.util.TextUtil;
import org.apache.commons.lang3.StringUtils;
@@ -661,17 +662,24 @@ public class ComputerUtilMana {
return false;
}
// LowPriorityAI SVar should be set to 'low' elsewhere to indicate that it is a low priority spell ability
AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
int chanceToReserve = aic.getIntProperty(AiProps.RESERVE_MANA_FOR_MAIN2_CHANCE);
// If it's a low priority spell (it's explicitly marked so elsewhere in the AI with a SVar), always
// obey mana reservations; otherwise, obey mana reservations depending on the "chance to reserve"
// AI profile variable.
if (sa.getSVar("LowPriorityAI").equals("")) {
if (chanceToReserve == 0 || MyRandom.getRandom().nextInt(100) >= chanceToReserve) {
return false;
}
}
PhaseType curPhase = ai.getGame().getPhaseHandler().getPhase();
if (curPhase == PhaseType.MAIN2 || curPhase == PhaseType.CLEANUP) {
((PlayerControllerAi)ai.getController()).getAi().getCardMemory().clearMemorySet(AiCardMemory.MemorySet.HELD_MANA_SOURCES);
aic.getCardMemory().clearMemorySet(AiCardMemory.MemorySet.HELD_MANA_SOURCES);
}
else {
if (((PlayerControllerAi)ai.getController()).getAi().getCardMemory().isRememberedCard(sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES)) {
if (aic.getCardMemory().isRememberedCard(sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES)) {
// This mana source is held elsewhere for a Main Phase 2 spell.
return true;
}

View File

@@ -5,3 +5,5 @@ DEFAULT_PLANAR_DIE_ROLL_CHANCE=50
MULLIGAN_THRESHOLD=5
PLANAR_DIE_ROLL_HESITATION_CHANCE=10
MOVE_EQUIPMENT_TO_BETTER_CREATURES=from_useless_only
RESERVE_MANA_FOR_MAIN2_CHANCE=0

View File

@@ -5,3 +5,4 @@ DEFAULT_PLANAR_DIE_ROLL_CHANCE=100
MULLIGAN_THRESHOLD=3
PLANAR_DIE_ROLL_HESITATION_CHANCE=0
MOVE_EQUIPMENT_TO_BETTER_CREATURES=always
RESERVE_MANA_FOR_MAIN2_CHANCE=0