Building a learning agent
Let's see how to build a learning agent that can achieve a goal. The learning agent will learn how to achieve a goal. Create a new python file and import the following package:
import argparse import gym
Define a function to parse the input arguments:
def build_arg_parser(): parser = argparse.ArgumentParser(description='Run an environment') parser.add_argument('--input-env', dest='input_env', required=True, choices=['cartpole', 'mountaincar', 'pendulum'], help='Specify the name of the environment') return parser
Parse the input arguments:
if __name__=='__main__': args = build_arg_parser().parse_args() input_env = args.input_env
Build a mapping from the input arguments to the names of the environments in the OpenAI Gym package: ...
Get Artificial Intelligence with Python 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.