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
9a4d46c0
Commit
9a4d46c0
authored
Apr 23, 2020
by
Theo Delbecq
Browse files
Options
Browse Files
Download
Plain Diff
Resolution manuelle du conflit sur ArbreMinMax en local
parents
2b9f32ea
5464252f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
3 deletions
+143
-3
AlgoRechercheMinMax.class
build/classes/tictactoecodingame/AlgoRechercheMinMax.class
+0
-0
ArbreMinMax.class
build/classes/tictactoecodingame/ArbreMinMax.class
+0
-0
Generator.class
build/classes/tictactoecodingame/Generator.class
+0
-0
private.xml
nbproject/private/private.xml
+1
-0
AlgoRechercheMinMax.java
src/tictactoecodingame/AlgoRechercheMinMax.java
+129
-0
ArbreMinMax.java
src/tictactoecodingame/ArbreMinMax.java
+10
-0
Generator.java
src/tictactoecodingame/Generator.java
+3
-3
No files found.
build/classes/tictactoecodingame/AlgoRechercheMinMax.class
0 → 100644
View file @
9a4d46c0
File added
build/classes/tictactoecodingame/ArbreMinMax.class
View file @
9a4d46c0
No preview for this file type
build/classes/tictactoecodingame/Generator.class
View file @
9a4d46c0
No preview for this file type
nbproject/private/private.xml
View file @
9a4d46c0
...
...
@@ -12,6 +12,7 @@
<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>
...
...
src/tictactoecodingame/AlgoRechercheMinMax.java
0 → 100644
View file @
9a4d46c0
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
tictactoecodingame
;
import
java.util.ArrayList
;
/**
*
* @author Théo
*/
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*/
private
int
depth
;
private
Plateau
plateau
;
private
Joueur
target
;
private
Joueur
opponent
;
private
int
d_gen
;
public
AlgoRechercheMinMax
(
int
depth
,
int
d_gen
,
Joueur
joueur1
,
Joueur
joueur2
){
this
.
depth
=
depth
;
this
.
d_gen
=
d_gen
;
//Cet algo ne marche qu'avec des jeux à deux joueurs
target
=
joueur1
;
opponent
=
joueur2
;
}
public
void
setRandGenDepth
(
int
d_gen
){
this
.
d_gen
=
d_gen
;
}
public
void
setDepth
(
int
depth
){
this
.
depth
=
depth
;
}
public
void
setPlayers
(
Joueur
joueur1
,
Joueur
joueur2
){
target
=
joueur1
;
opponent
=
joueur2
;
}
public
int
getRandGenDepth
(
int
d_gen
){
return
d_gen
;
}
public
int
getDepth
(
int
depth
){
return
depth
;
}
public
Joueur
[]
getPlayers
(
Joueur
joueur1
,
Joueur
joueur2
){
Joueur
[]
players
=
{
target
,
opponent
};
return
players
;
}
public
Coup
meilleurCoup
(
Plateau
_plateau
,
Joueur
_joueur
,
boolean
_ponder
){
plateau
=
_plateau
;
plateau
.
sauvegardePosition
(
0
);
if
(
target
!=
_joueur
){
opponent
=
target
;
target
=
_joueur
;
}
ArbreMinMax
explore
=
new
ArbreMinMax
();
builder
(
explore
,
target
,
0
);
}
//Fonction auxiliaire récursive de création de l'arbre des coups possibles
private
void
builder
(
ArbreMinMax
t
,
Joueur
currentJoueur
,
int
currentDepth
){
//On commence par mettre le plateau à jour en fonction du coup théorique joué
if
(
currentDepth
==
0
){
plateau
.
restaurePosition
(
0
);
}
else
{
plateau
.
restaurePosition
(
currentDepth
-
1
);
plateau
.
joueCoup
(
t
.
getcoup
());
plateau
.
sauvegardePosition
(
currentDepth
);
}
//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
));
Joueur
winner
=
plateau
.
vainqueur
();
if
(
winner
==
target
){
a
.
setvalue
(
1
);
}
else
if
(
winner
==
opponent
){
a
.
setvalue
(-
1
);
}
else
{
a
.
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
));
int
c
=
Generator
.
random_tests
(
plateau
,
d_gen
,
target
);
a
.
setvalue
(
c
);
fils
.
add
(
a
);
plateau
.
annuleDernierCoup
();
}
t
.
setfils
(
fils
);
}
else
{
ArrayList
<
ArbreMinMax
>
fils
=
new
ArrayList
<
ArbreMinMax
>();
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
ArbreMinMax
a
=
new
ArbreMinMax
(
coups
.
get
(
i
));
if
(
currentJoueur
==
target
){
builder
(
a
,
opponent
,
currentDepth
+
1
);
}
else
{
builder
(
a
,
target
,
currentDepth
+
1
);
}
fils
.
add
(
a
);
}
t
.
setfils
(
fils
);
}
}
}
src/tictactoecodingame/ArbreMinMax.java
View file @
9a4d46c0
...
...
@@ -15,6 +15,8 @@ import static tictactoecodingame.Generator.random_tests;
public
class
ArbreMinMax
{
protected
int
value
;
//Coup théorique joué à ce noeud
protected
Coup
coup
;
protected
ArrayList
<
Coup
>
coups
;
protected
ArrayList
<
ArbreMinMax
>
fils
;
...
...
@@ -23,6 +25,10 @@ public class ArbreMinMax {
public
ArbreMinMax
(){
}
public
ArbreMinMax
(
Coup
coup
){
this
.
coup
=
coup
;
}
public
ArbreMinMax
(
int
value
,
ArrayList
coups
,
ArrayList
fils
){
this
.
value
=
value
;
this
.
fils
=
fils
;
...
...
@@ -61,6 +67,10 @@ public class ArbreMinMax {
}
}
public
Coup
getcoup
(){
return
coup
;
}
public
ArrayList
getcoups
(){
return
(
coups
);
}
...
...
src/tictactoecodingame/Generator.java
View file @
9a4d46c0
...
...
@@ -10,7 +10,7 @@ package tictactoecodingame;
* @author Théo
*/
public
class
Generator
{
public
static
int
random_tests
(
Plateau
plateau
,
int
nb_tests
)
{
public
static
int
random_tests
(
Plateau
plateau
,
int
nb_tests
,
Joueur
target
)
{
int
c
=
0
;
JoueurOrdi
player
=
new
JoueurOrdi
(
"player"
);
JoueurOrdi
opponent
=
new
JoueurOrdi
(
"oppo"
);
...
...
@@ -39,9 +39,9 @@ public class Generator {
}
Joueur
vainqueur
=
plateau
.
vainqueur
();
if
(
vainqueur
==
player
)
if
(
vainqueur
.
getIdJoueur
()
==
target
.
getIdJoueur
()
)
c
++;
else
if
(
vainqueur
==
player
)
else
if
(
vainqueur
.
getIdJoueur
()
!=
target
.
getIdJoueur
()
)
c
--;
plateau
.
restaurePosition
(
0
);
}
...
...
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