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
9da78a8c
Commit
9da78a8c
authored
Apr 27, 2020
by
TRAN Alain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace AlgoRechercheMinMax.java
parent
38cb9e19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
6 deletions
+25
-6
AlgoRechercheMinMax.java
src/tictactoecodingame/AlgoRechercheMinMax.java
+25
-6
No files found.
src/tictactoecodingame/AlgoRechercheMinMax.java
View file @
9da78a8c
...
...
@@ -16,8 +16,11 @@ import java.util.ArrayList;
public
class
AlgoRechercheMinMax
extends
AlgoRecherche
{
Joueur
humain
;
public
AlgoRechercheMinMax
(
Joueur
_joueur
){
humain
=
_joueur
;
Joueur
ordi
;
public
AlgoRechercheMinMax
(
Joueur
_ordi1
,
Joueur
_joueur1
){
ordi
=
_ordi1
;
humain
=
_joueur1
;
}
String
[][]
grille
=
{{
""
,
""
,
""
},{
""
,
""
,
""
},{
""
,
""
,
""
}};
...
...
@@ -28,13 +31,17 @@ public class AlgoRechercheMinMax extends AlgoRecherche {
double
inf
=
Double
.
POSITIVE_INFINITY
;
double
bestScore
=
-
1
*
inf
;
CoupTicTacToe
meilleur_coup
=
null
;
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
_joueur
);
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
joueCoup
(
coups
.
get
(
i
));
_plateau
.
joueCoup
(
coups
.
get
(
i
));
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"coup initial"
);
double
score
=
minimax
(
_plateau
,
humain
,
0
,
false
);
//False car l'ordi a déjà placé son premier coup
Coup
coup_provisoire
=
coups
.
get
(
i
);
_plateau
.
annuleDernierCoup
();
System
.
out
.
println
(
"annule coup initial"
);
System
.
out
.
println
(
_plateau
);
if
(
score
>
bestScore
){
bestScore
=
score
;
meilleur_coup
=
(
CoupTicTacToe
)
coup_provisoire
;
...
...
@@ -59,11 +66,17 @@ public class AlgoRechercheMinMax extends AlgoRecherche {
if
(
isMaximizing
)
{
//ordi qui joue
double
inf
=
Double
.
POSITIVE_INFINITY
;
double
bestScore
=
-
1
*
inf
;
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
_joueur
);
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
joueCoup
(
coups
.
get
(
i
));
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"coup ordi"
);
double
score
=
minimax
(
_plateau
,
humain
,
profondeur
+
1
,
false
);
System
.
out
.
println
(
"dernier coup "
+
_plateau
.
getDernierCoup
());
_plateau
.
annuleDernierCoup
();
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"coup ordi annulé"
);
System
.
out
.
println
(
"dernier coup "
+
_plateau
.
getDernierCoup
());
bestScore
=
max
(
score
,
bestScore
);
}
return
bestScore
;
...
...
@@ -74,8 +87,14 @@ public class AlgoRechercheMinMax extends AlgoRecherche {
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
humain
);
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
joueCoup
(
coups
.
get
(
i
));
// problème : Il faut que ce soit l'autre joueur qui joue ici
double
score
=
minimax
(
_plateau
,
_joueur
,
profondeur
+
1
,
true
);
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"coup humain"
);
double
score
=
minimax
(
_plateau
,
ordi
,
profondeur
+
1
,
true
);
System
.
out
.
println
(
"dernier coup "
+
_plateau
.
getDernierCoup
());
_plateau
.
annuleDernierCoup
();
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"coup humain annulé"
);
System
.
out
.
println
(
"dernier coup "
+
_plateau
.
getDernierCoup
());
bestScore
=
min
(
score
,
bestScore
);
}
...
...
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