From 1f3e8c5f994599ecf3a76d1f9c2b71ec8c9fedcb Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Mon, 6 Feb 2023 23:03:27 +0100 Subject: [PATCH] Update Implementation Methode AIGridGUI --- src/main/java/BattleShip/AIGridGUI.java | 16 ++++++++++++++++ target/classes/BattleShip/AIGridGUI.class | Bin 5755 -> 6013 bytes target/classes/Snake/Controller.class | Bin 267 -> 5899 bytes 3 files changed, 16 insertions(+) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index d251e69..4a3c5dc 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -212,6 +212,13 @@ public class AIGridGUI extends JPanel { d = moveDown(d); 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; } } + + public int moveRight(int r) { + int dirRight = r + 1; + if((dirRight >= (rows * columns)) || (dirRight % columns == 0)) { + return -1; + } else { + return dirRight; + } + } } diff --git a/target/classes/BattleShip/AIGridGUI.class b/target/classes/BattleShip/AIGridGUI.class index 115b6fe9b747cb90f44537c3218542e750f2ea3f..44a5878775297156ba84e24b650a39c70c6c8fb5 100644 GIT binary patch delta 1183 zcmY*YU29xb6kYqy$DO(Japxm}7Z2`QpQn#k0=Xe34-Bp?ZmP-&qEHFZkS*!qbe zA>fNBDjrlw&_I01L!uB<3g#i8^r5IfpthyZrnWIAX=>VhG?|R+oEZ{)m^6!2NBFgaSK-k;nxS=?LTt*wbI+uc4$t5&N+?MT=`{ufk7q{FVp{iB8= z%@Lb<0er~k;`9#@za>lRr`Yd3%M5=3HY#`&caeclenl25xQBpD;7Rk%56CM1#j2(z zy3aT<=mC)>-=i06SceZA>W_Gfy@{YHvlbr^mN}Ie8PsJyLmVeiFq9#@h{Jfu^dOGo z5o{6J_-^;~B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