bug sur la référence des tour dans avalamboard
This commit is contained in:
@@ -221,6 +221,12 @@ public class ArenaWindow extends JFrame {
|
||||
Thread arenaThread = new Thread(() -> {
|
||||
SwingUtilities.invokeLater(() -> progressDialog.setVisible(true));
|
||||
|
||||
// Statistiques pour déboguer
|
||||
int bot1Wins = 0;
|
||||
int bot2Wins = 0;
|
||||
int draws = 0;
|
||||
int errors = 0;
|
||||
|
||||
for (int i = 1; i <= nbParties; i++) {
|
||||
final int partieNum = i;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
@@ -234,6 +240,15 @@ public class ArenaWindow extends JFrame {
|
||||
Result result = game.run();
|
||||
String winner = getWinnerName(result, bot1Type, bot2Type);
|
||||
|
||||
// Mettre à jour les statistiques
|
||||
if (result == Result.WIN) {
|
||||
bot1Wins++;
|
||||
} else if (result == Result.LOSS) {
|
||||
bot2Wins++;
|
||||
} else if (result == Result.DRAW) {
|
||||
draws++;
|
||||
}
|
||||
|
||||
// Ajouter au tableau dans le thread EDT
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
tableModel.addRow(new Object[]{
|
||||
@@ -244,6 +259,7 @@ public class ArenaWindow extends JFrame {
|
||||
});
|
||||
});
|
||||
} catch (Exception e) {
|
||||
errors++;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
tableModel.addRow(new Object[]{
|
||||
"Partie " + partieNum,
|
||||
@@ -254,15 +270,34 @@ public class ArenaWindow extends JFrame {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Afficher les statistiques finales
|
||||
final int finalBot1Wins = bot1Wins;
|
||||
final int finalBot2Wins = bot2Wins;
|
||||
final int finalDraws = draws;
|
||||
final int finalErrors = errors;
|
||||
|
||||
// Fermer le dialogue et afficher le message de fin
|
||||
// Fermer le dialogue et afficher le message de fin avec statistiques
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
progressDialog.dispose();
|
||||
|
||||
String statsMessage = String.format(
|
||||
"Toutes les parties sont terminées !\n\n" +
|
||||
"Statistiques :\n" +
|
||||
"- %s (Bot 1) : %d victoires\n" +
|
||||
"- %s (Bot 2) : %d victoires\n" +
|
||||
"- Matchs nuls : %d\n" +
|
||||
"- Erreurs : %d",
|
||||
bot1Type, finalBot1Wins,
|
||||
bot2Type, finalBot2Wins,
|
||||
finalDraws,
|
||||
finalErrors
|
||||
);
|
||||
|
||||
Object[] options = {"OK", "Quitter le jeu"};
|
||||
int choice = JOptionPane.showOptionDialog(
|
||||
this,
|
||||
"Toutes les parties sont terminées !",
|
||||
statsMessage,
|
||||
"Arène terminée",
|
||||
JOptionPane.DEFAULT_OPTION,
|
||||
JOptionPane.INFORMATION_MESSAGE,
|
||||
|
||||
@@ -51,9 +51,16 @@ public class AvalamBoard extends AbstractBoard {
|
||||
super(startingPlayer, new ArrayDeque<>());
|
||||
this.grid = new Tower[SIZE][SIZE];
|
||||
|
||||
// Copie profonde : créer de nouvelles tours pour éviter que toutes les parties partagent les mêmes objets
|
||||
for (int r = 0; r < SIZE; r++)
|
||||
for (int c = 0; c < SIZE; c++)
|
||||
this.grid[r][c] = initialGrid[r][c];
|
||||
for (int c = 0; c < SIZE; c++) {
|
||||
Tower t = initialGrid[r][c];
|
||||
if (t == null) {
|
||||
this.grid[r][c] = null;
|
||||
} else {
|
||||
this.grid[r][c] = new Tower(t.getHeight(), t.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -233,7 +233,6 @@ public class AvalamWindow extends JFrame {
|
||||
} else if (mode == GameMode.PVALPHA) {
|
||||
botMove = alphaBot.giveYourMove(board.safeCopy());
|
||||
} else {
|
||||
// A FAIRE PLUS TARD (PVGOD)
|
||||
botMove = divineBot.giveYourMove(board.safeCopy());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user