O'Reilly logo

Python Reinforcement Learning Projects by Rajalingappaa Shanmugamani, Yang Wenzhuo, Sean Saito

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

alphagozero_agent.py

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, go.py, 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required