Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
6ab40376
Commit
6ab40376
authored
8 years ago
by
Kilian Verhetsel
Browse files
Options
Downloads
Patches
Plain Diff
Pick best move by average, not upper bound, at the end of MC simulations
parent
6e6c4f1a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Mesh/search.hpp
+15
-6
15 additions, 6 deletions
Mesh/search.hpp
with
15 additions
and
6 deletions
Mesh/search.hpp
+
15
−
6
View file @
6ab40376
...
...
@@ -213,13 +213,22 @@ struct mcts_node {
return
std
::
distance
(
children
.
begin
(),
it
);
}
std
::
size_t
best_move
(
std
::
size_t
n
)
const
{
auto
it
=
std
::
max_element
(
children
.
begin
(),
children
.
end
(),
[
&
](
const
mcts_node
<
Score
>
&
a
,
const
mcts_node
<
Score
>
&
b
)
{
return
a
.
x_1
<
b
.
x_1
;
});
return
std
::
distance
(
children
.
begin
(),
it
);
}
};
/**
* Runs a single Monte Carlo Simulation as part of a Monte Carlo Tree Search.
*
* This operation is done as follows:
* 1. Explore the
seach
tree of statistics (
described by node
), playing
* 1. Explore the tree of statistics (
node being a pointer to its root
), playing
* optimially according to those statistics, until reaching
* one of its leaves.
* 2. Perform a completely random simulation, starting from the leaf found at
...
...
@@ -244,12 +253,12 @@ void mcts_simulation(mcts_node<Score> *node,
ancestors
.
push_back
(
node
);
bool
explore
=
true
;
bool
selection
=
true
;
while
(
!
actions
.
empty
())
{
std
::
size_t
i
;
if
(
explore
&&
node
->
children
.
size
()
==
0
)
{
if
(
selection
&&
node
->
children
.
size
()
==
0
)
{
node
->
children
.
resize
(
actions
.
size
());
i
=
rand
()
%
actions
.
size
();
...
...
@@ -257,9 +266,9 @@ void mcts_simulation(mcts_node<Score> *node,
node
=
&
node
->
children
[
i
];
ancestors
.
push_back
(
node
);
explore
=
false
;
selection
=
false
;
}
else
if
(
explore
)
{
else
if
(
selection
)
{
i
=
node
->
best_child
(
n
);
node
=
&
node
->
children
[
i
];
ancestors
.
push_back
(
node
);
...
...
@@ -321,7 +330,7 @@ void monte_carlo_tree_search(State &state, Successor &fn, Evaluator &eval) {
actions
.
begin
(),
actions
.
end
());
}
actions
[
node
.
best_
child
(
i
)](
state
).
apply
(
state
);
actions
[
node
.
best_
move
(
i
)](
state
).
apply
(
state
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment