Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Projet_info
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TRAN Alain
Projet_info
Commits
d83a2ca4
Commit
d83a2ca4
authored
May 03, 2020
by
MACE Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace Player.java
parent
1cfc0fbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
146 additions
and
82 deletions
+146
-82
Player.java
src/tictactoecodingame/Player.java
+146
-82
No files found.
src/tictactoecodingame/Player.java
View file @
d83a2ca4
package
tictactoecodingame
;
/**
*
* @author franck
*/
/*--------------------------------------------------------*/
/* Version jeu en local */
/*--------------------------------------------------------*/
public
class
Player
{
public
static
void
main
(
String
args
[])
{
JoueurHumain
humain
=
new
JoueurHumain
(
"Humain"
);
JoueurOrdi
joueurOrdi
=
new
JoueurOrdi
(
"Ordi"
);
// 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
);
GrilleTicTacToe3x3
grille
=
new
GrilleTicTacToe3x3
();
Arbitre
a
=
new
Arbitre
(
grille
,
joueurOrdi
,
humain
);
a
.
startNewGame
(
true
);
// Demarre une partie en affichant la grille du jeu
// Pour lancer un tournooi de 100 parties en affichant la grille du jeu
//a.startTournament(1000 , false);
}
}
/*--------------------------------------------------------*/
/* 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();
}
}
}
package
tictactoecodingame
;
/**
*
* @author franck
*/
/*--------------------------------------------------------*/
/* Version jeu en local */
/*--------------------------------------------------------*/
public
class
Player
{
public
static
void
main
(
String
args
[])
{
//Choisir le type de partie que vous souhaitez jouer:
//JOUEUR CONTRE MCTS 9x9
JoueurHumain
humain
=
new
JoueurHumain
(
"Humain"
);
JoueurOrdi
joueurOrdi
=
new
JoueurOrdi
(
"Ordi"
);
int
nbIteration
=
2000
;
//Augmenter le nombre d'itérations pour avoir un vrai challenge !
AlgoRechercheMCTS
mcts
=
new
AlgoRechercheMCTS
(
humain
,
nbIteration
);
joueurOrdi
.
setAlgoRecherche
(
mcts
);
GrilleTicTacToe9x9
grille
=
new
GrilleTicTacToe9x9
();
Arbitre
a
=
new
Arbitre
(
grille
,
joueurOrdi
,
humain
);
//JOUEUR CONTRE MCTS 3x3
/*
JoueurHumain humain = new JoueurHumain("Humain");
JoueurOrdi joueurOrdi = new JoueurOrdi("Ordi");
int nbIteration = 2000; //Augmenter le nombre d'itérations pour avoir un vrai challenge !
AlgoRechercheMCTS mcts = new AlgoRechercheMCTS(humain, nbIteration);
joueurOrdi.setAlgoRecherche(mcts);
GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3();
Arbitre a = new Arbitre(grille, joueurOrdi, humain);
*/
//MCTS vs MCTS 9x9
/*
JoueurOrdi joueurOrdi1 = new JoueurOrdi("Ordi1");
JoueurOrdi joueurOrdi2 = new JoueurOrdi("Ordi2");
AlgoRechercheMCTS mcts1 = new AlgoRechercheMCTS(joueurOrdi2, 2000);
AlgoRechercheMCTS mcts2 = new AlgoRechercheMCTS(joueurOrdi1, 5000);
joueurOrdi1.setAlgoRecherche(mcts1);
joueurOrdi2.setAlgoRecherche(mcts2);
GrilleTicTacToe9x9 grille = new GrilleTicTacToe9x9();
Arbitre a = new Arbitre(grille, joueurOrdi1 , joueurOrdi2);
*/
//MCTS vs MCTS 3x3
/*
JoueurOrdi joueurOrdi1 = new JoueurOrdi("Ordi1");
JoueurOrdi joueurOrdi2 = new JoueurOrdi("Ordi2");
AlgoRechercheMCTS mcts1 = new AlgoRechercheMCTS(joueurOrdi2, 2000);
AlgoRechercheMCTS mcts2 = new AlgoRechercheMCTS(joueurOrdi1, 5000);
joueurOrdi1.setAlgoRecherche(mcts1);
joueurOrdi2.setAlgoRecherche(mcts2);
GrilleTicTacToe3x3 grille = new GrilleTicTacToe3x3();
Arbitre a = new Arbitre(grille, joueurOrdi1 , joueurOrdi2);
*/
//MCTS vs ALEA 9x9
/*
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment