OpenAI Gym Setup
Basics
2 basic concepts:
1) the environment: the outside world;
2) the agent: the algorithm you are writing.
– The agent sends actions to the environment, and the environment replies with observations and rewards (a score).
The core gym interface: Env
https://github.com/openai/gym/blob/master/gym/core.py
To confirm Python’s version.
12 import platformprint(platform.python_version())
To confirm Python’s location from Terminal.
1 which python
Install Atari environments.
1 |
pip install -e '.[atari]' |
Prepare Python files like following examples and execute it from Terminal.
1 |
python cartpole.py |
Cart Pole
1 2 3 4 5 6 |
import gym env = gym.make('CartPole-v0') env.reset() for _ in range(1000): env.render() env.step(env.action_space.sample()) |
Space Invaders
1 2 3 4 5 6 7 |
import gym env = gym.make('SpaceInvaders-v0') env.reset() for _ in range(1000): env.render() env.step(env.action_space.sample()) |
Ms Pacman
1 2 3 4 5 6 7 |
import gym env = gym.make('MsPacman-v0') env.reset() for _ in range(1000): env.render() env.step(env.action_space.sample()) |
GIF Animation
To make a GIF animation.
1 2 3 |
git clone https://github.com/jakevdp/JSAnimation cd JSAnimation python setup.py install |