From cb07a19bb574ac96849a74cc9db4d97f99e7e9bb Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Mon, 6 Feb 2023 22:26:02 +0100 Subject: [PATCH] Update Implementation Methode AIGridGUI --- src/main/java/BattleShip/AIGridGUI.java | 14 ++++++++++++++ target/classes/BattleShip/AIGridGUI.class | Bin 4913 -> 5755 bytes 2 files changed, 14 insertions(+) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index 3f059a4..d251e69 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -206,6 +206,12 @@ public class AIGridGUI extends JPanel { u = moveUp(u); upCount++; } + int d = guessLocation; + int downCount = -1; + while(d >= 0 && !cellsHit[d]) { + d = moveDown(d); + downCount++; + } } } } @@ -221,4 +227,12 @@ public class AIGridGUI extends JPanel { return dirUp; } } + public int moveDown(int d) { + int dirDown = d + columns; + if(dirDown >= (rows*columns)) { + return -1; + } else { + return dirDown; + } + } } diff --git a/target/classes/BattleShip/AIGridGUI.class b/target/classes/BattleShip/AIGridGUI.class index 9814b983104401ef6f2a20478b7940a270f0e162..115b6fe9b747cb90f44537c3218542e750f2ea3f 100644 GIT binary patch delta 1596 zcmZWpZERCj7=GS++uruxw(C~9wRFms8H6cpxLK3ACDWPcj5?!`h$ah5TC>U4jeVd$ zG);6rG$xwRXyT?A0hy5sSq4J}&S-{FK#c=rl{)i16$Vc~l(eo#lQ zw)VA&6&*@+%!_d)ax2jt?T;si#*A%plhN6fjN8T@h3@Q0bae@&hi-d1>e_phTZs!i zahllw={26hQioC&Z@X3COZK$YC0bj%mUp%!;_2r-6#-|w zrE^6GeR5aa={=rh1wS$$4L@_p34^&v zDu7?$HgnA>!dajIU!>#2vDh#=L6dXD)3}YslNsYs$dv zL1p6V!=rO{jkZcP&&aYmTG2OqJQ}mKm^WngBT89&$g1c=ZfVFG#&wDtqcLBvpF|S_v;BiCfo>ONGZqtXV2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