Commit e3b4a453 authored by DELBECQ Théo's avatar DELBECQ Théo

Merge branch 'Theo' into 'master'

Mise à jour du Player et correction de bugs

See merge request !13
parents a9cdc1b5 e7106381
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -11,5 +11,5 @@ do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=C:\\Users\\theo\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
user.properties.file=C:\\Users\\theo\\AppData\\Roaming\\NetBeans\\11.3\\build.properties
>>>>>>> 4dd14568c244c833d17b679f8f3b340f997c8d04
......@@ -2,27 +2,6 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Coup.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/CoupTicTacToe.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Player.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Joueur.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/JoueurOrdi.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Arbre.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/AlgoRecherche.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/JoueurHumain.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/AlgoRechercheMinMax.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Jeton.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Case.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/ArbreMinMax.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Plateau.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Arbitre.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/AlgoRechercheAleatoire.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Generator.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/GrilleTicTacToe3x3.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/GrilleTicTacToe9x9.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Fraction.java</file>
<file>file:/C:/Users/theo/Documents/Ecole/IMT%20Lille%20Douai/L3/Projet%20Info/groupe3-tictactoe/src/tictactoecodingame/Piece.java</file>
</group>
<group/>
</open-files>
</project-private>
......@@ -14,8 +14,8 @@ import java.util.ArrayList;
public class AlgoRechercheMinMax extends AlgoRecherche{
/*La profondeur de recherche demandée doit être supérieure à 1 et inférieure
à 100, en pratique la croissance est factorielle en mémoire donc en ne
dépassera pas 10*/
à 98 (On commence à 0 et l'emplacement 99 est utilisée par le générateur),
en pratique la croissance est factorielle en mémoire donc en ne dépassera pas 10*/
private int depth;
private Plateau plateau;
private Joueur target;
......@@ -57,6 +57,7 @@ public class AlgoRechercheMinMax extends AlgoRecherche{
}
public Coup meilleurCoup( Plateau _plateau , Joueur _joueur , boolean _ponder ){
//On part du principe que la partie n'est pas terminée donc qu'il reste au moins un coup
plateau = _plateau;
plateau.sauvegardePosition(0);
if(target != _joueur){
......@@ -75,6 +76,7 @@ public class AlgoRechercheMinMax extends AlgoRecherche{
c = explore.getfils().get(i).getcoup();
}
}
plateau.restaurePosition(0);
return c;
}
......@@ -91,35 +93,21 @@ public class AlgoRechercheMinMax extends AlgoRecherche{
}
//On crée les nouveau noeuds à partir des coups disponible du point de vue du joueur à ce niveau de l'arbre
ArrayList<Coup> coups = plateau.getListeCoups(currentJoueur);
//On part du principe que la partie n'est pas terminée donc qu'il reste au moins un coup
if(coups.size()==1){
plateau.joueCoup(coups.get(0));
ArrayList<ArbreMinMax> fils = new ArrayList<ArbreMinMax>();
ArbreMinMax a = new ArbreMinMax(coups.get(0));
if(plateau.partieTerminee()){
Joueur winner = plateau.vainqueur();
if(winner == target){
a.setvalue(1);
t.setvalue(1);
}
else if(winner == opponent){
a.setvalue(-1);
t.setvalue(-1);
}
else {
a.setvalue(0);
t.setvalue(0);
}
fils.add(a);
t.setfils(fils);
}
else if (currentDepth == depth - 1){
ArrayList<ArbreMinMax> fils = new ArrayList<ArbreMinMax>();
for(int i=0; i<coups.size();i++){
plateau.joueCoup(coups.get(i));
ArbreMinMax a = new ArbreMinMax(coups.get(i));
else if (currentDepth == depth){
int c = Generator.random_tests(plateau, d_gen, target);
a.setvalue(c);
fils.add(a);
plateau.annuleDernierCoup();
}
t.setfils(fils);
t.setvalue(c);
}
else{
ArrayList<ArbreMinMax> fils = new ArrayList<ArbreMinMax>();
......
......@@ -115,7 +115,7 @@ public class ArbreMinMax {
}
public int Min(){
int m = 2147483640;
int m = Integer.MAX_VALUE;
int a = this.getfils().size();
for(int i = 0; i < a ; i++){
int n = this.getfils().get(i).getvalue();
......@@ -127,7 +127,7 @@ public class ArbreMinMax {
}
public int Max(){
int m = 0;
int m = Integer.MIN_VALUE;
int a = this.getfils().size();
for(int i = 0; i < a ; i++){
int n = this.getfils().get(i).getvalue();
......@@ -142,23 +142,22 @@ public class ArbreMinMax {
// c = compteur
// Le compteur doit être initialisé à 0 donc pair -> Max, impair -> Min
if(this.getfils() != null){
if(!this.estFeuille()){
int a = this.getfils().size();
for(int i = 0; i < a ; i++){
this.getfils().get(i).MinMax(c+1);
}
}
if(c%2 == 0){
//On attribue le Min
int m = this.Min();
//On attribue le max
int m = this.Max();
this.setvalue(m);
}
else{
//On attribue le max
int m = this.Max();
//On attribue le min
int m = this.Min();
this.setvalue(m);
}
}
}
}
......@@ -23,7 +23,7 @@ public class Generator {
opponent.forceId(i);
Coup coup;
plateau.sauvegardePosition(0);
plateau.sauvegardePosition(99);
for(i=0; i<nb_tests;i++){
while (!plateau.partieTerminee()) {
coup = currentPlayer.joue(plateau);
......@@ -39,11 +39,13 @@ public class Generator {
}
Joueur vainqueur = plateau.vainqueur();
if(vainqueur != null){
if ( vainqueur.getIdJoueur() == target.getIdJoueur() )
c++;
else if ( vainqueur.getIdJoueur() != target.getIdJoueur() )
c--;
plateau.restaurePosition(0);
}
plateau.restaurePosition(99);
}
return c;
}
......
......@@ -81,8 +81,7 @@ public class GrilleTicTacToe3x3 extends Plateau {
return false;
}
Joueur dernierJoueur = dernierCoup.getJeton()
.getJoueur();
Joueur dernierJoueur = dernierCoup.getJeton().getJoueur();
/* Regarde si le dernier coup est gagnant */
for (int d = 0; d < 4; d++) {
......
......@@ -12,21 +12,23 @@ public class Player {
public static void main(String args[]) {
JoueurHumain humain = new JoueurHumain("Humain");
JoueurOrdi joueurOrdi = new JoueurOrdi("Ordi");
//JoueurHumain humain = new JoueurHumain("Humain");
JoueurOrdi joueurOrdi1 = new JoueurOrdi("Ordi1");
JoueurOrdi joueurOrdi2 = new JoueurOrdi("Ordi2");
//Il faut deux joueurs car l'id fixe le jeton
// Remplacer ici l'algorithme aléatoire par votre algorithme.
// Créer une nouvelle classe qui hérite de la class AlgoRecherche
AlgoRechercheAleatoire alea = new AlgoRechercheAleatoire( ); // L'ordinateur joue au hasard
joueurOrdi.setAlgoRecherche(alea);
AlgoRechercheMinMax minmax = new AlgoRechercheMinMax(9, 100, joueurOrdi1, joueurOrdi2);
joueurOrdi1.setAlgoRecherche(minmax);
joueurOrdi2.setAlgoRecherche(minmax);
GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3();
//Arbitre a = new Arbitre(grille, joueurOrdi , joueurOrdi );
Arbitre a = new Arbitre(grille, joueurOrdi1 , joueurOrdi2);
Arbitre a = new Arbitre(grille, joueurOrdi , humain );
//Arbitre a = new Arbitre(grille, joueurOrdi , humain );
a.startNewGame(true); // Demarre une partie en affichant la grille du jeu
......
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