diff --git a/Projektgruppe_175/src/game/players/StrongAI.java b/Projektgruppe_175/src/game/players/StrongAI.java index 61f3b97..dd5dd67 100644 --- a/Projektgruppe_175/src/game/players/StrongAI.java +++ b/Projektgruppe_175/src/game/players/StrongAI.java @@ -15,6 +15,7 @@ import game.Player; import game.map.Castle; import game.map.PathFinding; import gui.AttackThread; +import gui.components.JokerPanel.JokerTypes; import gui.components.MapPanel.Action; public class StrongAI extends AI { @@ -39,8 +40,10 @@ public class StrongAI extends AI { private static double EVAL_OWN = 3.0; // Weight of own utilities private static double EVAL_OPP = -10.0; // Weight of opponents utilities + private static int scare_threshold = 5; // Number of troops to use scare joker + private boolean playedJoker1 = false; - private boolean playedJoker2 = false; + public StrongAI(String name, Color color) { @@ -306,6 +309,11 @@ public class StrongAI extends AI { } // Attack, if the chance of taking the castle is more useful than not attacking if(bestScore > evaluateState(game, g, this, Optional.empty()) && a.getTroopCount() > best.getTroopCount()) { + if(best.getTroopCount() > scare_threshold || getBatch(g, best.getOwner(), best, new ArrayList<>()).size() == 1) { + if(getJokers()[1] == JokerTypes.SCARE_TROOPS) { + playScareJoker(best, game); + } + } AttackThread attackThread = game.startAttack(a, best, a.getTroopCount()); if(fastForward) attackThread.fastForward(); @@ -320,29 +328,16 @@ public class StrongAI extends AI { return false; } - /** - * Play some jokers - * @param game the current game - */ - private void playJokers(Game game) { - if(!playedJoker1) { - if(this.getCastles(game).size() <= game.getMap().getCastles().size()/2) { - playedJoker1 = true; - System.out.println("StrongAI played joker 1."); - this.addTroops(5); - } - } - if(!playedJoker2) { - // TODO: Play joker 2 - } - } - @Override protected void actions(Game game) throws InterruptedException { if(game.getRound() == 1) { chooseInitialCastles(game); }else { - playJokers(game); + if(!playedJoker1) { + if(getJokers()[0] == JokerTypes.ADD_TROOPS) { + playTroopsJoker(); + } + } distributeTroops(game); boolean shouldAttack = false; do {