- PyTorch 1.x Reinforcement Learning Cookbook
- Yuxi (Hayden) Liu
- 249字
- 2021-06-24 12:34:39
How it works...
Using Gym, we can easily create an environment instance by calling the make() method with the name of the environment as the parameter.
As you may have noticed, the actions that the agent performs are randomly chosen using the sample() method.
Note that, normally, we would have a more sophisticated agent guided by reinforcement learning algorithms. Here, we just demonstrated how to simulate an environment, and how an agent takes actions regardless of the outcome.
Run this a few times and see what we get:
>>> env.action_space.sample()
0
>>> env.action_space.sample()
3
>>> env.action_space.sample()
0
>>> env.action_space.sample()
4
>>> env.action_space.sample()
2
>>> env.action_space.sample()
1
>>> env.action_space.sample()
4
>>> env.action_space.sample()
5
>>> env.action_space.sample()
1
>>> env.action_space.sample()
0
There are six possible actions in total. We can also see this by running the following command:
>>> env.action_space
Discrete(6)
Actions from 0 to 5 stand for No Operation, Fire, Up, Right, Left, and Down, respectively, which are all the moves the spaceship in the game can do.
The step() method will let the agent take the action that is specified as its parameter. The render() method will update the display window based on the latest observation of the environment.
The observation of the environment, new_state, is represented by a 210 x 160 x 3 matrix, as follows:
>>> print(new_state.shape)
(210, 160, 3)
This means that each frame of the display screen is an RGB image of size 210 x 160.
- 工業機器人產品應用實戰
- PowerShell 3.0 Advanced Administration Handbook
- TestStand工業自動化測試管理(典藏版)
- 大數據時代
- PostgreSQL 10 Administration Cookbook
- TensorFlow Reinforcement Learning Quick Start Guide
- Containers in OpenStack
- 嵌入式操作系統原理及應用
- Unity Multiplayer Games
- 統計挖掘與機器學習:大數據預測建模和分析技術(原書第3版)
- R Machine Learning Projects
- 計算機組成與操作系統
- 工業機器人實操進階手冊
- Artificial Intelligence By Example
- 人工智能:智能人機交互