- Fixed the logic for the AI planar die roll chance.

- Added an ability to set a chance for the AI hesitating to roll a planar die (default AI at 10%, reckless AI at 0%).
This commit is contained in:
Agetian
2013-07-04 15:47:32 +00:00
parent 6ebfe9b630
commit abf7382520
4 changed files with 13 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
MULLIGAN_THRESHOLD=5
DEFAULT_MAX_PLANAR_DIE_ROLLS_PER_TURN=1
DEFAULT_PLANAR_DIE_ROLL_CHANCE=50
MULLIGAN_THRESHOLD=5
PLANAR_DIE_ROLL_HESITATION_CHANCE=10

View File

@@ -1,3 +1,4 @@
MULLIGAN_THRESHOLD=2
DEFAULT_MAX_PLANAR_DIE_ROLLS_PER_TURN=1
DEFAULT_PLANAR_DIE_ROLL_CHANCE=100
MULLIGAN_THRESHOLD=2
PLANAR_DIE_ROLL_HESITATION_CHANCE=0

View File

@@ -23,6 +23,7 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
boolean decideToRoll = false;
int maxActivations = aic.getIntProperty(AiProps.DEFAULT_MAX_PLANAR_DIE_ROLLS_PER_TURN);
int chance = aic.getIntProperty(AiProps.DEFAULT_PLANAR_DIE_ROLL_CHANCE);
int hesitationChance = aic.getIntProperty(AiProps.PLANAR_DIE_ROLL_HESITATION_CHANCE);
if (!plane.hasSVar("AIRollPlanarDieInMain1") && ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)) {
return false;
@@ -39,7 +40,7 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
if (plane.hasSVar("AIRollPlanarDieChance")) {
chance = Integer.parseInt(plane.getSVar("AIRollPlanarDieChance"));
}
if (MyRandom.getRandom().nextInt(100) >= chance) {
if (MyRandom.getRandom().nextInt(100) < chance) {
decideToRoll = true;
}
break;
@@ -56,6 +57,11 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
decideToRoll = false;
}
// check if the AI hesitates
if (MyRandom.getRandom().nextInt(100) < hesitationChance) {
decideToRoll = false; // hesitate
}
return decideToRoll ? true : false;
}

View File

@@ -26,7 +26,8 @@ package forge.game.ai;
public enum AiProps { /** */
DEFAULT_MAX_PLANAR_DIE_ROLLS_PER_TURN ("1"), /** */
DEFAULT_PLANAR_DIE_ROLL_CHANCE ("50"), /** */
MULLIGAN_THRESHOLD ("5"); /** */
MULLIGAN_THRESHOLD ("5"), /** */
PLANAR_DIE_ROLL_HESITATION_CHANCE ("10"); /** */
private final String strDefaultVal;