Browse Source

Refratoring attemps

main
Thoumi Ngonga Brice 2 years ago
parent
commit
7f5ab5a893
  1. 8
      src/main/java/BattleShip/AIGridGUI.java

8
src/main/java/BattleShip/AIGridGUI.java

@ -252,7 +252,7 @@ public class AIGridGUI extends JPanel {
} else { } else {
//If nonrandom guess (locked onto a particular ship that has been hit but not killed), determine where to guess. //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) { while(!isClear) {
attempts++; 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 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(); guessLocation = directions.get(1).getCell();
} }
if(attempts == 2) {
if(attempts == 3) {
guessLocation = directions.get(2).getCell(); guessLocation = directions.get(2).getCell();
} }
if(attempts == 3) {
if(attempts == 4) {
guessLocation = directions.get(3).getCell(); guessLocation = directions.get(3).getCell();
} }

Loading…
Cancel
Save