ChessEngine: Limit MCTSTree expansion

This method temperate the habit of Monte-Carlo based algorithms to
repeatedly create new nodes.

It was first implemented in `Efficient Selectivity and Backup Operators
in Monte-Carlo Tree Search` by Rémi Coulom.
This commit is contained in:
Lucas CHOLLET 2022-08-14 13:09:00 +02:00 committed by Andreas Kling
parent 4c081e0479
commit 5f13a87ce7
Notes: sideshowbarker 2024-07-17 08:03:37 +09:00
2 changed files with 10 additions and 1 deletions

View File

@ -98,7 +98,15 @@ void MCTSTree::apply_result(int game_score)
void MCTSTree::do_round()
{
auto& node = select_leaf().expand();
// Note: Limit expansion to spare some memory
// Efficient Selectivity and Backup Operators in Monte-Carlo Tree Search.
// Rémi Coulom.
auto* node_ptr = &select_leaf();
if (node_ptr->m_simulations > s_number_of_visit_parameter)
node_ptr = &select_leaf().expand();
auto& node = *node_ptr;
int result;
if constexpr (s_eval_method == EvalMethod::Simulation) {

View File

@ -37,6 +37,7 @@ private:
// While static parameters are less configurable, they don't take up any
// memory in the tree, which I believe to be a worthy tradeoff.
static constexpr double s_exploration_parameter { M_SQRT2 };
static constexpr int s_number_of_visit_parameter { 1 };
// FIXME: Optimize simulations enough for use.
static constexpr EvalMethod s_eval_method { EvalMethod::Heuristic };