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
bf5e0be7
Commit
bf5e0be7
authored
May 02, 2020
by
TRAN Alain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace AlgoRechercheMinMax_9x9.java
parent
88930734
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
AlgoRechercheMinMax_9x9.java
src/tictactoecodingame/AlgoRechercheMinMax_9x9.java
+34
-4
No files found.
src/tictactoecodingame/AlgoRechercheMinMax_9x9.java
View file @
bf5e0be7
...
@@ -31,13 +31,14 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
...
@@ -31,13 +31,14 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
double
bestScore
=
-
1
*
inf
;
double
bestScore
=
-
1
*
inf
;
CoupTicTacToe
meilleur_coup
=
null
;
CoupTicTacToe
meilleur_coup
=
null
;
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
GrilleTicTacToe9x9
_plateau1
=
(
GrilleTicTacToe9x9
)
_plateau
;
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
sauvegardePosition
(
0
);
_plateau
.
sauvegardePosition
(
0
);
_plateau
.
joueCoup
(
coups
.
get
(
i
));
_plateau
.
joueCoup
(
coups
.
get
(
i
));
// System.out.println(_plateau);
// System.out.println(_plateau);
// System.out.println("coup initial");
// System.out.println("coup initial");
double
score
=
minimax
(
_plateau
,
humain
,
1
,
false
);
//False car l'ordi a déjà placé son premier coup
double
score
=
minimax
(
_plateau
1
,
humain
,
1
,
false
);
//False car l'ordi a déjà placé son premier coup
Coup
coup_provisoire
=
coups
.
get
(
i
);
Coup
coup_provisoire
=
coups
.
get
(
i
);
_plateau
.
restaurePosition
(
0
);
_plateau
.
restaurePosition
(
0
);
// System.out.println("annule coup initial");
// System.out.println("annule coup initial");
...
@@ -51,7 +52,7 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
...
@@ -51,7 +52,7 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
// changer le tour du joueur
// changer le tour du joueur
}
}
public
double
minimax
(
Plateau
_plateau
,
Joueur
_joueur
,
int
profondeur
,
boolean
isMaximizing
){
public
double
minimax
(
GrilleTicTacToe9x9
_plateau
,
Joueur
_joueur
,
int
profondeur
,
boolean
isMaximizing
){
if
(
_plateau
.
partieTerminee
()){
if
(
_plateau
.
partieTerminee
()){
if
(
_plateau
.
partieNulle
()){
if
(
_plateau
.
partieNulle
()){
...
@@ -66,12 +67,12 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
...
@@ -66,12 +67,12 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
// System.out.println("resultat " + resultat);
// System.out.println("resultat " + resultat);
return
scores
[
resultat
];}
return
scores
[
resultat
];}
else
{
else
{
//
return 0;
return
0
;
}
}
}
}
}
}
if
(
profondeur
>
1
){
if
(
profondeur
>
1
){
return
scores
[
1
]
;
return
evaluation
(
_plateau
)
;
}
}
...
@@ -118,6 +119,35 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
...
@@ -118,6 +119,35 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
return
bestScore
;
return
bestScore
;
}
}
}
}
public
double
evaluation
(
GrilleTicTacToe9x9
_plateau
){
double
delta
=
0
;
for
(
int
i
=
0
;
i
<
3
;
i
++){
// abscisse de la case 3x3
for
(
int
j
=
0
;
j
<
3
;
j
++){
//ordonnée de la case 3x3
for
(
int
k
=
0
;
k
<
3
;
k
++){
// absisse de la case 9x9
for
(
int
l
=
0
;
k
<
3
;
l
++){
// ordonnée de la case 9x9
Jeton
p
=
_plateau
.
grille9x9
[
3
*
i
+
k
][
3
*
j
+
l
];
if
(
p
!=
null
&&
p
.
getJoueur
()
==
humain
){
if
(
_plateau
.
caseGagnante
(
_plateau
.
grille9x9
,
3
*
i
,
3
*
j
,
3
*
i
+
k
,
3
*
j
+
l
)){
// Si on gagne
delta
=
delta
+
10
;
return
delta
;}
}
if
(
p
!=
null
&&
p
.
getJoueur
()
==
ordi
){
if
(
_plateau
.
caseGagnante
(
_plateau
.
grille9x9
,
3
*
i
,
3
*
j
,
3
*
i
+
k
,
3
*
j
+
l
)){
// Si on gagne
delta
=
delta
-
10
;
return
delta
;}
}
}
}
}
}
return
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