Browse Source

Update Implementation Methode AIGridGUI

main
Thoumi Ngonga Brice 2 years ago
parent
commit
677818f24f
  1. 15
      src/main/java/BattleShip/AIGridGUI.java

15
src/main/java/BattleShip/AIGridGUI.java

@ -219,6 +219,13 @@ public class AIGridGUI extends JPanel {
r = moveRight(r); r = moveRight(r);
rightCount++; 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; return dirRight;
} }
} }
public int moveLeft(int l) {
int dirLeft = l - 1;
if((dirLeft < 0) || (l % columns == 0)) {
return -1;
} else {
return dirLeft;
}
}
} }
Loading…
Cancel
Save