Commit d83a2ca4 authored by MACE Lloyd's avatar MACE Lloyd

Replace Player.java

parent 1cfc0fbe
package tictactoecodingame; package tictactoecodingame;
/** /**
* *
* @author franck * @author franck
*/ */
/*--------------------------------------------------------*/ /*--------------------------------------------------------*/
/* Version jeu en local */ /* Version jeu en local */
/*--------------------------------------------------------*/ /*--------------------------------------------------------*/
public class Player {
public static void main(String args[]) { public class Player {
JoueurHumain humain = new JoueurHumain("Humain"); public static void main(String args[]) {
JoueurOrdi joueurOrdi = new JoueurOrdi("Ordi");
//Choisir le type de partie que vous souhaitez jouer:
// Remplacer ici l'algorithme aléatoire par votre algorithme. //JOUEUR CONTRE MCTS 9x9
// Créer une nouvelle classe qui hérite de la class AlgoRecherche
AlgoRechercheAleatoire alea = new AlgoRechercheAleatoire( ); // L'ordinateur joue au hasard JoueurHumain humain = new JoueurHumain("Humain");
joueurOrdi.setAlgoRecherche(alea); JoueurOrdi joueurOrdi = new JoueurOrdi("Ordi");
GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3(); int nbIteration = 2000; //Augmenter le nombre d'itérations pour avoir un vrai challenge !
AlgoRechercheMCTS mcts = new AlgoRechercheMCTS(humain, nbIteration);
Arbitre a = new Arbitre(grille, joueurOrdi , humain ); joueurOrdi.setAlgoRecherche(mcts);
a.startNewGame(true); // Demarre une partie en affichant la grille du jeu GrilleTicTacToe9x9 grille = new GrilleTicTacToe9x9();
// Pour lancer un tournooi de 100 parties en affichant la grille du jeu Arbitre a = new Arbitre(grille, joueurOrdi, humain);
//a.startTournament(1000 , false);
} //JOUEUR CONTRE MCTS 3x3
} /*
JoueurHumain humain = new JoueurHumain("Humain");
/*--------------------------------------------------------*/ JoueurOrdi joueurOrdi = new JoueurOrdi("Ordi");
/* Version Codin game */
/*--------------------------------------------------------*/ int nbIteration = 2000; //Augmenter le nombre d'itérations pour avoir un vrai challenge !
AlgoRechercheMCTS mcts = new AlgoRechercheMCTS(humain, nbIteration);
/* joueurOrdi.setAlgoRecherche(mcts);
import java.util.Scanner;
GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3();
Arbitre a = new Arbitre(grille, joueurOrdi, humain);
class Player { */
public static void main(String args[]) { //MCTS vs MCTS 9x9
/*
Scanner in = new Scanner(System.in); JoueurOrdi joueurOrdi1 = new JoueurOrdi("Ordi1");
JoueurOrdi joueurOrdi2 = new JoueurOrdi("Ordi2");
CoupTicTacToe3x3 coup;
JoueurHumain adversaire = new JoueurHumain("Adversaire"); AlgoRechercheMCTS mcts1 = new AlgoRechercheMCTS(joueurOrdi2, 2000);
JoueurOrdi joueurOrdi = new JoueurOrdi("Ordi"); AlgoRechercheMCTS mcts2 = new AlgoRechercheMCTS(joueurOrdi1, 5000);
joueurOrdi1.setAlgoRecherche(mcts1);
AlgoRechercheAleatoire alea = new AlgoRechercheAleatoire( ); // L'ordinateur joue au hasard joueurOrdi2.setAlgoRecherche(mcts2);
joueurOrdi.setAlgoRecherche(alea);
GrilleTicTacToe9x9 grille = new GrilleTicTacToe9x9();
GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3();
grille.init(); Arbitre a = new Arbitre(grille, joueurOrdi1 , joueurOrdi2);
*/
while (true) { //MCTS vs MCTS 3x3
int opponentRow = in.nextInt(); /*
int opponentCol = in.nextInt(); JoueurOrdi joueurOrdi1 = new JoueurOrdi("Ordi1");
int validActionCount = in.nextInt(); JoueurOrdi joueurOrdi2 = new JoueurOrdi("Ordi2");
for (int i = 0; i < validActionCount; i++) {
int row = in.nextInt(); AlgoRechercheMCTS mcts1 = new AlgoRechercheMCTS(joueurOrdi2, 2000);
int col = in.nextInt(); AlgoRechercheMCTS mcts2 = new AlgoRechercheMCTS(joueurOrdi1, 5000);
} joueurOrdi1.setAlgoRecherche(mcts1);
if ( opponentCol != -1 ) { joueurOrdi2.setAlgoRecherche(mcts2);
coup = new CoupTicTacToe3x3(opponentCol, opponentRow, new Jeton(adversaire));
grille.joueCoup(coup); GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3();
}
Arbitre a = new Arbitre(grille, joueurOrdi1 , joueurOrdi2);
coup = (CoupTicTacToe3x3) joueurOrdi.joue(grille); */
grille.joueCoup(coup);
System.out.println(coup.getLigne() + " " + coup.getColonne() ); //MCTS vs ALEA 9x9
System.out.flush(); /*
} JoueurOrdi joueurOrdi1 = new JoueurOrdi("Ordi1");
} JoueurOrdi joueurOrdi2 = new JoueurOrdi("Ordi2");
} AlgoRechercheMCTS mcts = new AlgoRechercheMCTS(joueurOrdi2, 2000);
AlgoRechercheAleatoire alea = new AlgoRechercheAleatoire();
joueurOrdi1.setAlgoRecherche(mcts);
joueurOrdi2.setAlgoRecherche(alea);
GrilleTicTacToe9x9 grille = new GrilleTicTacToe9x9();
Arbitre a = new Arbitre(grille, joueurOrdi1 , joueurOrdi2);
*/
//Choisir de jouer une partie ou un tournoi :
//a.startNewGame(true);
a.startTournament(100, true);
}
}
/*--------------------------------------------------------*/
/* Version Codin game */
/*--------------------------------------------------------*/
/*
import java.util.Scanner;
class Player {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
CoupTicTacToe3x3 coup;
JoueurHumain adversaire = new JoueurHumain("Adversaire");
JoueurOrdi joueurOrdi = new JoueurOrdi("Ordi");
AlgoRechercheAleatoire alea = new AlgoRechercheAleatoire( ); // L'ordinateur joue au hasard
joueurOrdi.setAlgoRecherche(alea);
GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3();
grille.init();
while (true) {
int opponentRow = in.nextInt();
int opponentCol = in.nextInt();
int validActionCount = in.nextInt();
for (int i = 0; i < validActionCount; i++) {
int row = in.nextInt();
int col = in.nextInt();
}
if ( opponentCol != -1 ) {
coup = new CoupTicTacToe3x3(opponentCol, opponentRow, new Jeton(adversaire));
grille.joueCoup(coup);
}
coup = (CoupTicTacToe3x3) joueurOrdi.joue(grille);
grille.joueCoup(coup);
System.out.println(coup.getLigne() + " " + coup.getColonne() );
System.out.flush();
}
}
}
*/ */
\ No newline at end of file
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