Building a learning agent
In this section, we will build upon the work from our first cartpole example. Initially, the cartpole was just moving around. We are now going to try to balance the pole on top of the cart and try to make sure the pole stays upright. Ready to learn some more? Let's get to it.
First, create a new Python file and import the following packages:
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...