diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index d251e69..4a3c5dc 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -212,6 +212,13 @@ public class AIGridGUI extends JPanel { d = moveDown(d); downCount++; } + + int r = guessLocation; + int rightCount = -1; + while(r >= 0 && !cellsHit[r]) { + r = moveRight(r); + rightCount++; + } } } } @@ -235,4 +242,13 @@ public class AIGridGUI extends JPanel { return dirDown; } } + + public int moveRight(int r) { + int dirRight = r + 1; + if((dirRight >= (rows * columns)) || (dirRight % columns == 0)) { + return -1; + } else { + return dirRight; + } + } } diff --git a/target/classes/BattleShip/AIGridGUI.class b/target/classes/BattleShip/AIGridGUI.class index 115b6fe..44a5878 100644 Binary files a/target/classes/BattleShip/AIGridGUI.class and b/target/classes/BattleShip/AIGridGUI.class differ diff --git a/target/classes/Snake/Controller.class b/target/classes/Snake/Controller.class index 5bee98b..c4eef7e 100644 Binary files a/target/classes/Snake/Controller.class and b/target/classes/Snake/Controller.class differ