Commit f23df28e authored by TRAN Alain's avatar TRAN Alain

Replace AlgoRechercheMinMax_9x9.java

parent 2b4df17a
......@@ -30,24 +30,29 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
double inf = Double.POSITIVE_INFINITY;
double bestScore = -1 * inf;
CoupTicTacToe meilleur_coup = null ;
GrilleTicTacToe9x9 _plateau1 = (GrilleTicTacToe9x9) _plateau;
CoupTicTacToe coup_humain = _plateau1.dernierCoup;
ArrayList<Coup> coups = _plateau.getListeCoups(ordi);
// GrilleTicTacToe9x9 _plateau1 = (GrilleTicTacToe9x9) _plateau;
for (int i = 0; i < coups.size(); i++){
_plateau.sauvegardePosition(0);
_plateau.joueCoup(coups.get(i));
// System.out.println(_plateau);
// System.out.println("coup initial");
System.out.println("Coups dispo ordi initial " + coups);
System.out.println(_plateau);
System.out.println("coup initial");
double score = minimax(_plateau,humain,1,false); //False car l'ordi a déjà placé son premier coup
Coup coup_provisoire = coups.get(i);
_plateau.restaurePosition(0);
// System.out.println("annule coup initial");
// System.out.println(_plateau);
System.out.println("annule coup initial");
System.out.println(_plateau);
System.out.println("dernier coup initial " + _plateau.getDernierCoup());
if (score > bestScore){
bestScore = score;
meilleur_coup = (CoupTicTacToe)coup_provisoire;
}
}
}
_plateau1.dernierCoup = coup_humain;
return meilleur_coup;
// changer le tour du joueur
}
......@@ -80,6 +85,7 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
double inf = Double.POSITIVE_INFINITY;
double bestScore = -1 * inf;
ArrayList<Coup> coups = _plateau.getListeCoups(ordi);
// System.out.println("Coups dispo ordi " + coups);
for (int i = 0; i < coups.size(); i++){
_plateau.sauvegardePosition(profondeur);
_plateau.joueCoup(coups.get(i));
......@@ -100,6 +106,7 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
double inf = Double.POSITIVE_INFINITY;
double bestScore = inf;
ArrayList<Coup> coups = _plateau.getListeCoups(humain);
// System.out.println("Coups dispo humain " + coups);
for (int i = 0; i < coups.size(); i++){
_plateau.sauvegardePosition(profondeur);
_plateau.joueCoup(coups.get(i));
......@@ -127,7 +134,8 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
for(int j = 0; j < 3; j++){ //ordonnée de la case 3x3
for(int k = 0; k < 3; k++){ // absisse de la case 9x9
for(int l = 0; l< 3; l++){ // ordonnée de la case 9x9
Jeton p = _plateau.grille9x9[3*i + k][3*j + l];
Case case1 = new Case(3*i + k, 3*j + l);
Piece p = _plateau.getPiece(case1);
if (p!= null && p.getJoueur() == humain){
if (_plateau.caseGagnante(_plateau.grille9x9, 3*i, 3*j, 3*i + k, 3*j + l)){ // Si on gagne
delta = delta + 10;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment