diff --git a/src/player/MalteAI.java b/src/player/MalteAI.java index d7f1759..dc518eb 100644 --- a/src/player/MalteAI.java +++ b/src/player/MalteAI.java @@ -1,6 +1,8 @@ package player; import java.util.Random; +import java.util.Set; +import java.util.HashSet; public class Player2 implements Player{ @@ -13,11 +15,14 @@ public class Player2 implements Player{ } public int move(int[][] board){ - int choice = ran.nextInt(7); - while (board[choice][0] != 0) { - choice = ran.nextInt(7); + Set options = new HashSet<>([0, 1, 2, 3, 4, 5, 6]); + for (Integer i: options) { + if (board[i][0] != 0) { + options.remove(i); + } } - return choice; + + return 0; } public String getName(){