diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index 3f059a4..d251e69 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -206,6 +206,12 @@ public class AIGridGUI extends JPanel { u = moveUp(u); upCount++; } + int d = guessLocation; + int downCount = -1; + while(d >= 0 && !cellsHit[d]) { + d = moveDown(d); + downCount++; + } } } } @@ -221,4 +227,12 @@ public class AIGridGUI extends JPanel { return dirUp; } } + public int moveDown(int d) { + int dirDown = d + columns; + if(dirDown >= (rows*columns)) { + return -1; + } else { + return dirDown; + } + } } diff --git a/target/classes/BattleShip/AIGridGUI.class b/target/classes/BattleShip/AIGridGUI.class index 9814b98..115b6fe 100644 Binary files a/target/classes/BattleShip/AIGridGUI.class and b/target/classes/BattleShip/AIGridGUI.class differ