contains our implementation of Monte Carlo tree search. Our first class is RootNode, which is meant to represent the root node of the MCTS tree at the start of a simulation. By definition, the root node does not have a parent. Having a separate class for the root node is not absolutely necessary, but it does keep the code cleaner:

import collectionsimport mathimport numpy as npimport utilsfrom config import MCTSPARAMETERS, GOPARAMETERSclass RootNode(object):    def __init__(self):        self.parent_node = None        self.child_visit_counts = collections.defaultdict(float)        self.child_cumulative_rewards = collections.defaultdict(float)

Next, we implement the MCTreeSearchNode class. This class has several attributes, the most important ones ...

Get Python Reinforcement Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.