From d94b95fa36a88373f69498ef1c325e6a5304e900 Mon Sep 17 00:00:00 2001 From: felix-vi Date: Thu, 5 Feb 2026 20:50:23 +0100 Subject: [PATCH] =?UTF-8?q?erreur=20de=20cr=C3=A9ation=20dans=20l'ar=C3=A8?= =?UTF-8?q?ne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fr/iut_fbleau/Avalam/ArenaWindow.java | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/fr/iut_fbleau/Avalam/ArenaWindow.java b/fr/iut_fbleau/Avalam/ArenaWindow.java index 1df16a9..68b074e 100644 --- a/fr/iut_fbleau/Avalam/ArenaWindow.java +++ b/fr/iut_fbleau/Avalam/ArenaWindow.java @@ -192,22 +192,10 @@ public class ArenaWindow extends JFrame { * @param nbParties nombre de parties à jouer */ private void runArena(String bot1Type, String bot2Type, int depth, int nbParties) { - // Créer les bots - AbstractGamePlayer bot1 = createBot(bot1Type, Player.PLAYER1, depth); - AbstractGamePlayer bot2 = createBot(bot2Type, Player.PLAYER2, depth); - - if (bot1 == null || bot2 == null) { - JOptionPane.showMessageDialog(this, "Erreur lors de la création des bots."); - return; - } - // Vider le tableau tableModel.setRowCount(0); results.clear(); - // Charger le plateau initial - Tower[][] initialGrid = BoardLoader.loadFromFile("fr/iut_fbleau/Res/Plateau.txt"); - // Créer un dialogue de progression JDialog progressDialog = new JDialog(this, "Parties en cours...", true); JLabel progressLabel = new JLabel("Préparation des parties...", JLabel.CENTER); @@ -233,6 +221,26 @@ public class ArenaWindow extends JFrame { progressLabel.setText("Partie " + partieNum + " / " + nbParties + " en cours..."); }); + // Recréer les bots à chaque partie pour garantir l'indépendance complète + // (notamment pour réinitialiser les générateurs aléatoires) + AbstractGamePlayer bot1 = createBot(bot1Type, Player.PLAYER1, depth); + AbstractGamePlayer bot2 = createBot(bot2Type, Player.PLAYER2, depth); + + if (bot1 == null || bot2 == null) { + errors++; + SwingUtilities.invokeLater(() -> { + tableModel.addRow(new Object[]{ + "Partie " + partieNum, + bot1Type, + bot2Type, + "Erreur: Impossible de créer les bots" + }); + }); + continue; + } + + // Recharger le plateau à chaque partie pour garantir l'indépendance complète + Tower[][] initialGrid = BoardLoader.loadFromFile("fr/iut_fbleau/Res/Plateau.txt"); AvalamBoard board = new AvalamBoard(initialGrid, Player.PLAYER1); ArenaGame game = new ArenaGame(board, bot1, bot2);