Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/Raymo111/Battleship
Browse files Browse the repository at this point in the history
  • Loading branch information
yichunShen committed Jun 18, 2018
2 parents fcbc6b5 + 9ed4cd2 commit 1e67879
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/AI.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,21 @@ public AI(boolean inGui) throws IOException {

// User wants to offset edges
if (input.equalsIgnoreCase("y")) {
int x = Integer.parseInt(br.readLine()) - 1;
int y = Integer.parseInt(br.readLine()) - 1;
for (int i = 0; i < Battleship.enemyGrid.length; i++)
for (int j = 0; j < Battleship.enemyGrid[i].length; j++) {
if (Battleship.enemyGrid[i][j].x == 1 || Battleship.enemyGrid[i][j].x == 8) {// x in outer 2

// X between x and y layers
if (Battleship.enemyGrid[i][j].x >= x && Battleship.enemyGrid[i][j].x <= y
|| Battleship.enemyGrid[i][j].x <= 9 - y && Battleship.enemyGrid[i][j].x >= 9 - x) {
Battleship.enemyGrid[i][j].huntPDx += 40;
Battleship.enemyGrid[i][j].combinehuntPDXY();
}
if (Battleship.enemyGrid[i][j].y == 1 || Battleship.enemyGrid[i][j].y == 8) {// y in outer 2

// Y between x and y layers
if (Battleship.enemyGrid[i][j].y >= x && Battleship.enemyGrid[i][j].y <= y
|| Battleship.enemyGrid[i][j].y <= 9 - y && Battleship.enemyGrid[i][j].y >= 9 - x) {
Battleship.enemyGrid[i][j].huntPDy += 40;
Battleship.enemyGrid[i][j].combinehuntPDXY();
}
Expand Down

0 comments on commit 1e67879

Please sign in to comment.