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
1206c04c
Commit
1206c04c
authored
Apr 27, 2020
by
TRAN Alain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace AlgoRechercheMinMax.java
parent
9da78a8c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
22 deletions
+28
-22
AlgoRechercheMinMax.java
src/tictactoecodingame/AlgoRechercheMinMax.java
+28
-22
No files found.
src/tictactoecodingame/AlgoRechercheMinMax.java
View file @
1206c04c
...
...
@@ -24,7 +24,7 @@ public class AlgoRechercheMinMax extends AlgoRecherche {
}
String
[][]
grille
=
{{
""
,
""
,
""
},{
""
,
""
,
""
},{
""
,
""
,
""
}};
double
[]
scores
=
{
1
,-
1
,
0
};
double
[]
scores
=
{
-
1
,
1
,
0
};
@Override
public
Coup
meilleurCoup
(
Plateau
_plateau
,
Joueur
_joueur
,
boolean
ponder
){
...
...
@@ -34,14 +34,16 @@ public class AlgoRechercheMinMax extends AlgoRecherche {
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
sauvegardePosition
(
0
);
_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
//
System.out.println(_plateau);
//
System.out.println("coup initial");
double
score
=
minimax
(
_plateau
,
humain
,
1
,
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
);
// _plateau.annuleDernierCoup();
_plateau
.
restaurePosition
(
0
);
//System.out.println("annule coup initial");
//System.out.println(_plateau);
if
(
score
>
bestScore
){
bestScore
=
score
;
meilleur_coup
=
(
CoupTicTacToe
)
coup_provisoire
;
...
...
@@ -68,15 +70,17 @@ public class AlgoRechercheMinMax extends AlgoRecherche {
double
bestScore
=
-
1
*
inf
;
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
sauvegardePosition
(
profondeur
);
_plateau
.
joueCoup
(
coups
.
get
(
i
));
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"coup ordi"
);
//
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
());
//System.out.println("dernier coup " + _plateau.getDernierCoup());
//_plateau.annuleDernierCoup();
_plateau
.
restaurePosition
(
profondeur
);
//System.out.println(_plateau);
//System.out.println("coup ordi annulé");
//System.out.println("dernier coup " + _plateau.getDernierCoup());
bestScore
=
max
(
score
,
bestScore
);
}
return
bestScore
;
...
...
@@ -86,15 +90,17 @@ public class AlgoRechercheMinMax extends AlgoRecherche {
double
bestScore
=
inf
;
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
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"coup humain"
);
_plateau
.
sauvegardePosition
(
profondeur
);
_plateau
.
joueCoup
(
coups
.
get
(
i
));
//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
());
//System.out.println("dernier coup " + _plateau.getDernierCoup());
//_plateau.annuleDernierCoup();
_plateau
.
restaurePosition
(
profondeur
);
//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