Browse Source

Update Implementation Methode AIGridGUI

main
Thoumi Ngonga Brice 2 years ago
parent
commit
1f3e8c5f99
  1. 16
      src/main/java/BattleShip/AIGridGUI.java
  2. BIN
      target/classes/BattleShip/AIGridGUI.class
  3. BIN
      target/classes/Snake/Controller.class

16
src/main/java/BattleShip/AIGridGUI.java

@ -212,6 +212,13 @@ public class AIGridGUI extends JPanel {
d = moveDown(d); d = moveDown(d);
downCount++; downCount++;
} }
int r = guessLocation;
int rightCount = -1;
while(r >= 0 && !cellsHit[r]) {
r = moveRight(r);
rightCount++;
}
} }
} }
} }
@ -235,4 +242,13 @@ public class AIGridGUI extends JPanel {
return dirDown; return dirDown;
} }
} }
public int moveRight(int r) {
int dirRight = r + 1;
if((dirRight >= (rows * columns)) || (dirRight % columns == 0)) {
return -1;
} else {
return dirRight;
}
}
} }

BIN
target/classes/BattleShip/AIGridGUI.class

BIN
target/classes/Snake/Controller.class

Loading…
Cancel
Save