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
b1ca7639
Commit
b1ca7639
authored
Apr 21, 2020
by
CRESCENCE Cassandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete AlgoRechercheAleatoire.java
parent
e262c9d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
93 deletions
+0
-93
AlgoRechercheAleatoire.java
src/mcts_cassandre/AlgoRechercheAleatoire.java
+0
-93
No files found.
src/mcts_cassandre/AlgoRechercheAleatoire.java
deleted
100644 → 0
View file @
e262c9d6
/*
* 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.lang.Math
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
/**
*
* @author franck.tempet
*/
public
class
AlgoRechercheAleatoire
extends
AlgoRecherche
{
Random
rnd
;
public
AlgoRechercheAleatoire
()
{
rnd
=
new
Random
();
}
// PHASE DE SELECTION
public
static
double
uctValue
(
int
totalVisit
,
double
nodeWinScore
,
int
nodeVisit
)
{
// méthode pour calculer UCT du noeud enfant d'un noeud parent donné
if
(
nodeVisit
==
0
){
return
Integer
.
MAX_VALUE
;
}
return
nodeWinScore
/((
double
)
nodeVisit
)
+
1
,
41
*
Math
.
sqrt
((
double
)
Math
.
log
(
(
double
)
(
totalVisit
/
nodeVisit
)));
}
public
Node
selectNodeWithBestUCT
(
Node
parent
){
// méthode pour sélectionner le noeud enfant qui a le plus grand UCT
double
max
=
Integer
.
MIN_VALUE
;
int
totalVisit
=
parent
.
getState
().
getVisitCount
();
for
(
Coup
child
:
parent
.
getChildArray
()){
double
uctValue
=
uctValue
(
totalVisit
,
child
.
getState
().
getWinScore
(),
child
.
getState
().
getVisitCount
()
);
if
(
uctValue
>
max
){
max
=
uctValue
;
Node
selectedNode
=
child
;
}
}
return
selectedNode
;
}
// PHASE D'EXPANSION
public
static
void
expandNode
(
Node
node
){
ArrayList
<
Coup
>
coupsPossible
=
node
.
getState
().
getAllPossibleStates
();
for
(
Coup
coup
:
coupsPossible
){
State
newState
=
new
State
(
Plateau
node
.
getState
().
getPlateau
()
,
Joueur
node
.
getParent
().
getState
().
getJoueur
()
,
0
,
0
););
Node
newNode
=
new
Node
();
newNode
.
setState
(
newState
);
newNode
.
setParent
(
Node
node
);
newNode
.
setChildArray
(
ArrayList
<
Coup
>
newNode
.
setChildArray
()
);
}
}
// PHASE DE SIMULATION
public
static
boolean
simulationFromNode
(
Node
node
){
State
state
=
node
.
getState
();
Joueur
joueur
=
state
.
getJoueur
();
if
(
partieTerminee
()
!=
true
){
randomPlay
(
Plateau
state
.
getPlateau
(),
Joueur
state
.
getJoueur
(),
boolean
_ponder
);
}
if
(
vainqueur
()
==
joueur
){
return
true
;
}
if
(
vainqueur
()
!=
joueur
){
return
false
;
}
}
@Override
public
Coup
meilleurCoup
(
Plateau
_plateau
,
Joueur
_joueur
,
boolean
_ponder
)
{
ArrayList
<
Coup
>
coups
=
_plateau
.
getListeCoups
(
_joueur
);
return
coups
.
get
(
rnd
.
nextInt
(
coups
.
size
()));
}
}
}
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