diff --git a/src/GomokuAI.java b/src/GomokuAI.java index 618c992..1fdf95e 100644 --- a/src/GomokuAI.java +++ b/src/GomokuAI.java @@ -24,7 +24,7 @@ public class GomokuAI extends Player { /** The random initialization */ Random random = new Random(); /** The difficulty of the GomokuAI */ - private int difficulty = 1; + private int difficulty = 2; // ------------------Methods-------------------------- /** @@ -45,7 +45,7 @@ public class GomokuAI extends Player { playCell = playableCell.get(random.nextInt(playableCell.size())); break; case 1: - Map map = GetCellPoint(board); + Map map = GetCellPoint(board,this.color); int max = 0; for (Map.Entry entry : map.entrySet()) { if (entry.getValue() > max) { @@ -53,6 +53,35 @@ public class GomokuAI extends Player { playCell = entry.getKey(); } } + break; + case 2: + Map map2 = GetCellPoint(board,this.color); + Color other = null; + if(this.color == Color.WHITE) { + other = Color.BLACK; + } + else{ + other = Color.WHITE; + } + Map map3 = GetCellPoint(board,other); + + int max3 = 0; + int max2 = 0; + for (Map.Entry entry : map2.entrySet()) { + if (entry.getValue() > max2) { + max2 = entry.getValue(); + playCell = entry.getKey(); + } + } + + for (Map.Entry entry : map3.entrySet()) { + if (entry.getValue() > max3) { + max3 = entry.getValue(); + playCell = entry.getKey(); + } + } + + break; default: throw new AssertionError(); @@ -69,8 +98,8 @@ public class GomokuAI extends Player { * @param board The actual Gomoku board. * @return the Map of all Cell playable, and their point. */ - public Map GetCellPoint(GomokuBoard board) { - + public Map GetCellPoint(GomokuBoard board,Color color) { + // Prout List playableCell = board.getPlayableCells(); Map map = new HashMap<>();