From 7f5ab5a893c2b8d397b7495803c4bd4b2c1cf5c6 Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Tue, 7 Feb 2023 21:50:00 +0100 Subject: [PATCH] Refratoring attemps --- src/main/java/BattleShip/AIGridGUI.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index bf9c8ac..c012d19 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -252,7 +252,7 @@ public class AIGridGUI extends JPanel { } else { //If nonrandom guess (locked onto a particular ship that has been hit but not killed), determine where to guess. - int attempts = 1; + int attempts = 0; while(!isClear) { attempts++; @@ -306,15 +306,15 @@ public class AIGridGUI extends JPanel { //If first guess is not clear or is out of bounds, continue trying other directions until one is found that works. - if(attempts == 1) { + if(attempts == 2) { guessLocation = directions.get(1).getCell(); } - if(attempts == 2) { + if(attempts == 3) { guessLocation = directions.get(2).getCell(); } - if(attempts == 3) { + if(attempts == 4) { guessLocation = directions.get(3).getCell(); }