Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Groupe3-TicTacToe
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
BAHRMAN Louis
Groupe3-TicTacToe
Commits
b12b3e5f
Commit
b12b3e5f
authored
Apr 28, 2020
by
Timothy LAIRD
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Base commit
parent
16f9b55e
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
27 additions
and
39 deletions
+27
-39
AlgoRechercheMCTS.class
build/classes/tictactoecodingame/AlgoRechercheMCTS.class
+0
-0
ArbreMCTS.class
build/classes/tictactoecodingame/ArbreMCTS.class
+0
-0
Fraction.class
build/classes/tictactoecodingame/Fraction.class
+0
-0
Node.class
build/classes/tictactoecodingame/Node.class
+0
-0
Player.class
build/classes/tictactoecodingame/Player.class
+0
-0
private.xml
nbproject/private/private.xml
+15
-5
AlgoRechercheMCTS.java
src/tictactoecodingame/AlgoRechercheMCTS.java
+4
-5
ArbreMCTS.java
src/tictactoecodingame/ArbreMCTS.java
+1
-1
Fraction.java
src/tictactoecodingame/Fraction.java
+1
-1
Node.java
src/tictactoecodingame/Node.java
+3
-25
Player.java
src/tictactoecodingame/Player.java
+3
-2
No files found.
build/classes/tictactoecodingame/AlgoRechercheMCTS.class
View file @
b12b3e5f
No preview for this file type
build/classes/tictactoecodingame/ArbreMCTS.class
View file @
b12b3e5f
No preview for this file type
build/classes/tictactoecodingame/Fraction.class
View file @
b12b3e5f
No preview for this file type
build/classes/tictactoecodingame/Node.class
View file @
b12b3e5f
No preview for this file type
build/classes/tictactoecodingame/Player.class
View file @
b12b3e5f
No preview for this file type
nbproject/private/private.xml
View file @
b12b3e5f
<?xml version="1.0" encoding="UTF-8"?>
<project-private
xmlns=
"http://www.netbeans.org/ns/project-private/1"
>
<editor-bookmarks
xmlns=
"http://www.netbeans.org/ns/editor-bookmarks/2"
lastBookmarkId=
"0"
/>
<editor-bookmarks
xmlns=
"http://www.netbeans.org/ns/editor-bookmarks/2"
lastBookmarkId=
"1"
>
<file>
<url>
src/tictactoecodingame/AlgoRechercheMCTS.java
</url>
<bookmark
id=
"1"
>
<name/>
<line>
97
</line>
<key/>
</bookmark>
</file>
</editor-bookmarks>
<open-files
xmlns=
"http://www.netbeans.org/ns/projectui-open-files/2"
>
<group>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/tmp/src/tictactoecodingame/Fraction.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/tmp/src/tictactoecodingame/Node.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/tmp/src/tictactoecodingame/Arbre.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/tmp/src/tictactoecodingame/AlgoRechercheMCTS.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/TicTacToe/src/tictactoecodingame/ArbreMCTS.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/TicTacToe/src/tictactoecodingame/Node.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/TicTacToe/src/tictactoecodingame/Fraction.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/TicTacToe/src/tictactoecodingame/AlgoRechercheMCTS.java
</file>
<file>
file:/C:/Users/timot/OneDrive/Desktop/2019-2020/Projet-Informatique/TicTacToe/src/tictactoecodingame/Player.java
</file>
</group>
</open-files>
</project-private>
src/tictactoecodingame/AlgoRechercheMCTS.java
View file @
b12b3e5f
...
...
@@ -38,8 +38,8 @@ public class AlgoRechercheMCTS extends AlgoRecherche {
}
Joueur
winner
=
simulate
(
nextNode
);
update
(
winner
,
nextNode
);
}
Node
nextPlay
=
root
.
nextPlay
();
search
.
root
(
nextPlay
);
return
nextPlay
.
board
().
getDernierCoup
();
...
...
@@ -56,7 +56,7 @@ public class AlgoRechercheMCTS extends AlgoRecherche {
private
void
expansion
(
Node
leaf
){
ArrayList
<
Coup
>
coups
=
leaf
.
getCoups
();
Iterator
<
Coup
>
coup
=
coups
.
iterator
();
Plateau
leafPlateau
=
(
new
Node
(
leaf
.
board
(),
null
,
null
,
null
))
.
board
();
Plateau
leafPlateau
=
leaf
.
board
();
Coup
currentCoup
;
while
(
coup
.
hasNext
()){
currentCoup
=
coup
.
next
();
...
...
@@ -68,8 +68,7 @@ public class AlgoRechercheMCTS extends AlgoRecherche {
}
private
Joueur
simulate
(
Node
node
){
Node
tmp
=
new
Node
(
node
.
board
(),
node
.
player
(),
node
.
opponent
(),
node
.
parent
());
Plateau
board
=
tmp
.
board
();
Plateau
board
=
node
.
board
();
Joueur
p1
=
node
.
player
();
Joueur
p2
=
node
.
opponent
();
Joueur
currentPlayer
=
node
.
player
();
Random
seed
=
new
Random
();
...
...
@@ -90,7 +89,7 @@ public class AlgoRechercheMCTS extends AlgoRecherche {
Node
currentNode
=
node
;
while
(
currentNode
!=
null
){
currentNode
.
addVisit
();
if
(
currentNode
.
player
()
==
winner
){
if
(
currentNode
.
player
()
.
equals
(
winner
)
){
currentNode
.
addWin
();
}
currentNode
=
currentNode
.
parent
();
...
...
src/tictactoecodingame/ArbreMCTS.java
View file @
b12b3e5f
...
...
@@ -13,7 +13,7 @@ public class ArbreMCTS {
Node
root
;
public
ArbreMCTS
(
Joueur
pl
,
Joueur
o
){
root
=
new
Node
(
null
,
pl
,
o
,
null
);
root
=
new
Node
(
null
,
pl
,
o
);
}
public
Node
root
(){
...
...
src/tictactoecodingame/Fraction.java
View file @
b12b3e5f
...
...
@@ -17,7 +17,7 @@ public class Fraction {
if
(
visits
==
0
){
return
Integer
.
MAX_VALUE
;
}
return
(
wins
/
visits
)
*
1.41
*
Math
.
sqrt
(
Math
.
log
(
parentVisit
)
/
visits
);
return
(
wins
/
visits
)
+
1.41
*
Math
.
sqrt
(
Math
.
log
(
parentVisit
)
/
visits
);
}
public
static
Node
bestChild
(
Node
root
){
...
...
src/tictactoecodingame/Node.java
View file @
b12b3e5f
...
...
@@ -12,34 +12,20 @@ import java.util.Iterator;
* @author timot
*/
public
class
Node
{
Plateau
board
;
Coup
coup
;
Joueur
player
;
Joueur
opponent
;
int
visits
=
0
;
int
wins
=
0
;
Node
parent
;
ArrayList
<
Node
>
children
;
public
Node
(
Plateau
b
,
Joueur
pl
,
Joueur
o
,
Node
pr
){
board
=
b
;
public
Node
(
Coup
c
,
Joueur
pl
,
Joueur
o
){
coup
=
c
;
player
=
pl
;
opponent
=
o
;
parent
=
pr
;
children
=
new
ArrayList
<>();
}
public
Node
(
Plateau
b
){
board
=
b
;
}
public
ArrayList
<
Coup
>
getCoups
(){
return
board
.
getListeCoups
(
player
);
}
public
Node
parent
(){
return
parent
;
}
public
int
visits
(){
return
visits
;
}
...
...
@@ -48,10 +34,6 @@ public class Node {
return
wins
;
}
public
Plateau
board
(){
return
board
;
}
public
Joueur
player
(){
return
player
;
}
...
...
@@ -72,10 +54,6 @@ public class Node {
wins
++;
}
public
void
board
(
Plateau
p
){
board
=
p
;
}
public
Node
nextPlay
(){
Node
bestNode
=
null
;
double
winrate
=
0
;
...
...
src/tictactoecodingame/Player.java
View file @
b12b3e5f
...
...
@@ -18,13 +18,13 @@ public class Player {
// Remplacer ici l'algorithme aléatoire par votre algorithme.
// Créer une nouvelle classe qui hérite de la class AlgoRecherche
AlgoRecherche
Aleatoire
alea
=
new
AlgoRechercheAleatoire
(
);
// L'ordinateur joue au hasard
AlgoRecherche
MCTS
alea
=
new
AlgoRechercheMCTS
(
joueurOrdi
,
humain
);
// L'ordinateur joue au hasard
joueurOrdi
.
setAlgoRecherche
(
alea
);
GrilleTicTacToe3x3
grille
=
new
GrilleTicTacToe3x3
();
Arbitre
a
=
new
Arbitre
(
grille
,
joueurOrdi
,
joueurOrdi
);
Arbitre
a
=
new
Arbitre
(
grille
,
humain
,
joueurOrdi
);
// Arbitre a = new Arbitre(grille, joueurOrdi , humain );
...
...
@@ -32,6 +32,7 @@ public class Player {
// Pour lancer un tournooi de 100 parties en affichant la grille du jeu
//a.startTournament(1000 , false);
}
}
...
...
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