From 4c5bbea894e20904081f20dc3a306e22cedc0ab5 Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Mon, 6 Feb 2023 21:57:43 +0100 Subject: [PATCH] Update Implementation Methode AIGridGUI --- src/main/java/BattleShip/AIGridGUI.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index dbefd40..5afe8d4 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -183,6 +183,13 @@ public class AIGridGUI extends JPanel { for(int i = 0; i < rows * columns; i++) { guesses[i] = i; } + Random rand = new Random(); + for(int i = 0; i < guesses.length; i++) { + int randInt = rand.nextInt(guesses.length); + int randGuess = guesses[randInt]; + guesses[randInt] = guesses[i]; + guesses[i] = randGuess; + } } } }