Creating an environment
We will be using a package called OpenAI Gym
to build reinforcement learning agents. You can learn more about it here:
https://gym.openai.com
. We can install it using pip by running the following command on the Terminal:
$ pip3 install gym
You can find various tips and tricks related to its installation here: https://github.com/openai/gym#installation . Now that you have installed it, let's go ahead and write some code.
Create a new python file and import the following package:
import argparse import gym
Define a function to parse the input arguments. We will be able to specify the type of environment we want to run:
def build_arg_parser(): parser = argparse.ArgumentParser(description='Run an environment') parser.add_argument('--input-env', ...
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.