Finally, we implement the agent that acts as the interface between the Go games and the algorithms. The main class we will implement is called AlphaGoZeroAgent. Again, this class combines PolicyValueNetwork with our MCTS module, as is done in AlphaGo Zero, to select moves and simulate games. Note that any missing modules (for example,, which implements the game of Go itself) can be found in the main GitHub repository:

import loggingimport osimport randomimport timeimport numpy as npimport goimport utilsfrom config import GLOBAL_PARAMETER_STORE, GOPARAMETERSfrom mcts import MCTreeSearchNodefrom utils import make_sgflogger = logging.getLogger(__name__)class AlphaGoZeroAgent:    def __init__(self, network, player_v_player ...

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.