diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index 4a3c5dc..984fd96 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -219,6 +219,13 @@ public class AIGridGUI extends JPanel { r = moveRight(r); rightCount++; } + + int l = guessLocation; + int leftCount = -1; + while(l >= 0 && !cellsHit[l]) { + l = moveLeft(l); + leftCount++; + } } } } @@ -251,4 +258,12 @@ public class AIGridGUI extends JPanel { return dirRight; } } + public int moveLeft(int l) { + int dirLeft = l - 1; + if((dirLeft < 0) || (l % columns == 0)) { + return -1; + } else { + return dirLeft; + } + } }