From c2cc054fa4a016dec7dd3af14c36b1b5301db00d Mon Sep 17 00:00:00 2001 From: Sesu8642 <45859254+Sesu8642@users.noreply.github.com> Date: Mon, 7 Oct 2024 23:31:24 +0200 Subject: [PATCH] make easy and medium bot levels biased against other bots --- .../feudaltactics/lib/ingame/botai/BotAi.java | 5 +++++ .../lib/ingame/botai/Intelligence.java | 21 ++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/BotAi.java b/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/BotAi.java index 63bc4577..99393720 100644 --- a/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/BotAi.java +++ b/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/BotAi.java @@ -36,6 +36,7 @@ import de.sesu8642.feudaltactics.lib.gamestate.InputValidationHelper; import de.sesu8642.feudaltactics.lib.gamestate.Kingdom; import de.sesu8642.feudaltactics.lib.gamestate.PalmTree; +import de.sesu8642.feudaltactics.lib.gamestate.Player.Type; import de.sesu8642.feudaltactics.lib.gamestate.Tree; import de.sesu8642.feudaltactics.lib.gamestate.Unit; import de.sesu8642.feudaltactics.lib.gamestate.Unit.UnitTypes; @@ -704,6 +705,10 @@ private OffenseTileScoreInfo getOffenseTileScoreInfo(GameState gameState, Intell if (!intelligence.smartAttacking) { score = 0; } + if (tile.getPlayer().getType() == Type.LOCAL_BOT) { + score += intelligence.attackOtherBotsBias; + } + return new OffenseTileScoreInfo(tile, score, requiredStrength); } diff --git a/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/Intelligence.java b/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/Intelligence.java index 5a3cb97d..e20f840e 100644 --- a/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/Intelligence.java +++ b/core/src/main/java/de/sesu8642/feudaltactics/lib/ingame/botai/Intelligence.java @@ -4,9 +4,9 @@ /** Possible intelligence levels for the AI. */ public enum Intelligence { - LEVEL_1(0.5F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, false, false), - LEVEL_2(0.8F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, false, true), - LEVEL_3(1F, 4, false, 25, 20, true, true), LEVEL_4(1F, 7, true, 25, 20, true, true); + LEVEL_1(0.5F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, 5, false, false), + LEVEL_2(0.8F, 0, false, Integer.MAX_VALUE, Integer.MAX_VALUE, 5, false, true), + LEVEL_3(1F, 4, false, 25, 20, 0, true, true), LEVEL_4(1F, 7, true, 25, 20, 0, true, true); /** Chance that the bot will even try to conquer anything in a given turn. */ public final float chanceToConquerPerTurn; @@ -38,29 +38,36 @@ public enum Intelligence { */ public final int protectWithUnitScoreTreshold; + /** + * Offense tile scores for other bot players will be increased by this amount to + * make the game easier for the human players. + */ + public final int attackOtherBotsBias; + /** * Whether to defend smartly: i.e. considering how many tiles are protected. If * false, the defense score of every tile is 0. This means that (basically) * random tiles near the border are protected. */ - boolean smartDefending; + public final boolean smartDefending; /** * Whether to attack smartly: prefer enemy kingdom tiles over unconnected ones, * destroy castles etc. If false, the offense score of every tile is 0. This * means that (basically) random tiles are conquered. */ - boolean smartAttacking; + public final boolean smartAttacking; private Intelligence(float chanceToConquerPerTurn, int blockingObjectRemovalScoreTreshold, boolean reconsidersWhichTilesToProtect, int protectWithCastleScoreTreshold, - int protectWithUnitScoreTreshold, boolean smartDefending, boolean smartAttacking) { + int protectWithUnitScoreTreshold, int attackOtherBotsBias, boolean smartDefending, boolean smartAttacking) { this.chanceToConquerPerTurn = chanceToConquerPerTurn; this.blockingObjectRemovalScoreTreshold = blockingObjectRemovalScoreTreshold; this.reconsidersWhichTilesToProtect = reconsidersWhichTilesToProtect; - this.smartDefending = smartDefending; this.protectWithCastleScoreTreshold = protectWithCastleScoreTreshold; this.protectWithUnitScoreTreshold = protectWithUnitScoreTreshold; + this.attackOtherBotsBias = attackOtherBotsBias; + this.smartDefending = smartDefending; this.smartAttacking = smartAttacking; }