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
f23df28e
Commit
f23df28e
authored
May 03, 2020
by
TRAN Alain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace AlgoRechercheMinMax_9x9.java
parent
2b4df17a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
AlgoRechercheMinMax_9x9.java
src/tictactoecodingame/AlgoRechercheMinMax_9x9.java
+14
-6
No files found.
src/tictactoecodingame/AlgoRechercheMinMax_9x9.java
View file @
f23df28e
...
...
@@ -30,24 +30,29 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
double
inf
=
Double
.
POSITIVE_INFINITY
;
double
bestScore
=
-
1
*
inf
;
CoupTicTacToe
meilleur_coup
=
null
;
GrilleTicTacToe9x9
_plateau1
=
(
GrilleTicTacToe9x9
)
_plateau
;
CoupTicTacToe
coup_humain
=
_plateau1
.
dernierCoup
;
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
// GrilleTicTacToe9x9 _plateau1 = (GrilleTicTacToe9x9) _plateau;
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");
System
.
out
.
println
(
"Coups dispo ordi initial "
+
coups
);
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
.
restaurePosition
(
0
);
// System.out.println("annule coup initial");
// System.out.println(_plateau);
System
.
out
.
println
(
"annule coup initial"
);
System
.
out
.
println
(
_plateau
);
System
.
out
.
println
(
"dernier coup initial "
+
_plateau
.
getDernierCoup
());
if
(
score
>
bestScore
){
bestScore
=
score
;
meilleur_coup
=
(
CoupTicTacToe
)
coup_provisoire
;
}
}
}
_plateau1
.
dernierCoup
=
coup_humain
;
return
meilleur_coup
;
// changer le tour du joueur
}
...
...
@@ -80,6 +85,7 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
double
inf
=
Double
.
POSITIVE_INFINITY
;
double
bestScore
=
-
1
*
inf
;
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
ordi
);
// System.out.println("Coups dispo ordi " + coups);
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
sauvegardePosition
(
profondeur
);
_plateau
.
joueCoup
(
coups
.
get
(
i
));
...
...
@@ -100,6 +106,7 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
double
inf
=
Double
.
POSITIVE_INFINITY
;
double
bestScore
=
inf
;
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
humain
);
// System.out.println("Coups dispo humain " + coups);
for
(
int
i
=
0
;
i
<
coups
.
size
();
i
++){
_plateau
.
sauvegardePosition
(
profondeur
);
_plateau
.
joueCoup
(
coups
.
get
(
i
));
...
...
@@ -127,7 +134,8 @@ public class AlgoRechercheMinMax_9x9 extends AlgoRecherche {
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
;
l
<
3
;
l
++){
// ordonnée de la case 9x9
Jeton
p
=
_plateau
.
grille9x9
[
3
*
i
+
k
][
3
*
j
+
l
];
Case
case1
=
new
Case
(
3
*
i
+
k
,
3
*
j
+
l
);
Piece
p
=
_plateau
.
getPiece
(
case1
);
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
;
...
...
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