AI In danger threshold now configurable and can be random instead of being locked to always 4.

(As a player, I find the fact the AI always changes their behavior towards more defensive at exactly 5 life extremely abusable - I can always be 100% sure they won't block certain creatures or activate certain spells/abilties otherwise, and in many cases, if the AI already got down to 5 life, even if they do activate their big trump card, it's too late : the last 5 damage is way easy to deal.)

Used this for playing the past few days and it seemed to work without problems.
This commit is contained in:
Seravy
2018-02-17 22:29:47 +01:00
parent 7ff8564077
commit 7f2d2d6588
3 changed files with 24 additions and 2 deletions

View File

@@ -103,9 +103,12 @@ public enum AiProps { /** */
BOUNCE_ALL_ELSEWHERE_NONCREAT_EVAL_DIFF ("3"), /** */ BOUNCE_ALL_ELSEWHERE_NONCREAT_EVAL_DIFF ("3"), /** */
INTUITION_ALTERNATIVE_LOGIC ("false"), /** */ INTUITION_ALTERNATIVE_LOGIC ("false"), /** */
EXPLORE_MAX_CMC_DIFF_TO_PUT_IN_GRAVEYARD ("2"), EXPLORE_MAX_CMC_DIFF_TO_PUT_IN_GRAVEYARD ("2"),
EXPLORE_NUM_LANDS_TO_STILL_NEED_MORE ("2"); /** */ EXPLORE_NUM_LANDS_TO_STILL_NEED_MORE("2"), /** */
// Experimental features, must be removed after extensive testing and, ideally, defaulting // Experimental features, must be removed after extensive testing and, ideally, defaulting
// <-- There are no experimental options here --> // <-- There are no experimental options here -->
AI_IN_DANGER_THRESHOLD("4"),
AI_IN_DANGER_MAX_THRESHOLD("4");
private final String strDefaultVal; private final String strDefaultVal;

View File

@@ -19,6 +19,7 @@ package forge.ai;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@@ -433,7 +434,18 @@ public class ComputerUtilCombat {
} }
} }
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) - payment < Math.min(4, ai.getLife()) int threshold = (((PlayerControllerAi) ai.getController()).getAi().getIntProperty(AiProps.AI_IN_DANGER_THRESHOLD));
int maxTreshold = (((PlayerControllerAi) ai.getController()).getAi().getIntProperty(AiProps.AI_IN_DANGER_MAX_THRESHOLD)) - threshold;
Random rand = new Random();
int chance = rand.nextInt(80) + 5;
while (maxTreshold > 0) {
if (rand.nextInt(100) < chance) {
threshold++;
}
maxTreshold--;
}
if (ComputerUtilCombat.lifeThatWouldRemain(ai, combat) - payment < Math.min(threshold, ai.getLife())
&& !ai.cantLoseForZeroOrLessLife()) { && !ai.cantLoseForZeroOrLessLife()) {
return true; return true;
} }

View File

@@ -200,4 +200,11 @@ EXPLORE_NUM_LANDS_TO_STILL_NEED_MORE=3
# -- features is over. These toggles will be removed later, or may be reintroduced under a -- # -- features is over. These toggles will be removed later, or may be reintroduced under a --
# -- different name if necessary -- # -- different name if necessary --
# If AI would drop to this amount of life in combat, it'll try to defend itself more actively
AI_IN_DANGER_THRESHOLD=3
# If set to the same value, AI will be predictable. If set to higher, AI will randomly pick a value between the two
# for each evaluation, introducing some unpredictability.
AI_IN_DANGER_MAX_THRESHOLD=12
# <-- there are no options here at the moment --> # <-- there are no options here at the moment -->