From 6a8f0f3c1d8d02ab738e69a0e4502f5a098251ec Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Mon, 6 Feb 2023 21:51:19 +0100 Subject: [PATCH] Update Implementation Methode AIGridGUI --- src/main/java/BattleShip/AIGridGUI.java | 29 ++++++++++++++++++++++ target/classes/BattleShip/AIGridGUI.class | Bin 2901 -> 4913 bytes 2 files changed, 29 insertions(+) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index ea4014d..dbefd40 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -156,4 +156,33 @@ public class AIGridGUI extends JPanel { return endGame; } + + public void go() { + //Play a turn by making a guess at a cell. + + int guessLocation = 0; + boolean gameOver = true; + numOfGuesses++; + BSButton b = null; + Ship s = null; + boolean killed = false; + boolean isClear = false; + + if(randomGuess) { + //Find out the maximum ship length of the surviving ships. + int minClearSpace = 0; + for(Ship sh : allShips) { + if(!sh.isKilled() && sh.getLength() > minClearSpace) { + minClearSpace = sh.getLength(); + } + } + + //Create an array of all possible cells and shuffle the order of the cells. Potential guesses are drawn from this array. + + int[] guesses = new int[(rows * columns)]; + for(int i = 0; i < rows * columns; i++) { + guesses[i] = i; + } + } + } } diff --git a/target/classes/BattleShip/AIGridGUI.class b/target/classes/BattleShip/AIGridGUI.class index e603c494a8fd0bf61d7e252dc389dea1f4b294da..9814b983104401ef6f2a20478b7940a270f0e162 100644 GIT binary patch delta 2266 zcmZuy32;+Y6g@9Xf0F*Pr&7vNhJk5IX?4Uh!{T78BOp))97aHp-}aM~rb$hHSsXEA zWkAsZHOh`46biC04P_AvA|SW`iaW|CqM#xu0+z<}ep+PI&g8xO-#hod`|dgS^+fXK zZmz=(JNE$SC$QO-Zx6emV4jNkSRmjiG4!Bj1cCy|=^2A3YLm2_3ZulAGq7>JPa+m! zv4SNk-oR3UR{wP$|!Fquf|Ku`U z^A`uoTv!LI95$)gEVE6N$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