teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

jupyter-gymn

2017/12/08 05:34

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -30,4 +30,9 @@
30
30
 
31
31
  >
32
32
  ```
33
- ![イメージ説明](c5632621ae1632bf56fefc18b3f13d8d.png)
33
+ ![イメージ説明](c5632621ae1632bf56fefc18b3f13d8d.png)
34
+
35
+ 検索してみたら面白いものが見つかりました。`jupyter`上で`gym`を動作させることができるようです。
36
+ 描画部分は`VNC`に渡すような感じのようです。
37
+ 導入のハードルは高そうですが、参考まで。
38
+ [paulsuda/jupyter-gym-vnc](https://github.com/paulsuda/jupyter-gym-vnc)

1

検証結果を追記

2017/12/08 05:34

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -1,4 +1,33 @@
1
1
  `full install`していなければ`pip install -e '.[classic_control]' `が必要と記載されています。
2
2
 
3
3
  [Classic control](https://github.com/openai/gym#classic-control)
4
- > If you didn't do the full install, you will need to run pip install -e '.[classic_control]' to enable rendering.
4
+ > If you didn't do the full install, you will need to run pip install -e '.[classic_control]' to enable rendering.
5
+
6
+ jupyter上でエラー再現しました。OpenGL描画のスクリーン取得できず失敗しているようです。
7
+ ターミナル上から実行すると、倒立振り子のウインドウが開き、正常に?動作しました。
8
+
9
+ ```Python
10
+ import gym
11
+ env = gym.make('CartPole-v0')
12
+ for i_episode in range(20):
13
+ observation = env.reset()
14
+ for t in range(100):
15
+ env.render()
16
+ print(observation)
17
+ action = env.action_space.sample()
18
+ observation, reward, done, info = env.step(action)
19
+ if done:
20
+ print("Episode finished after {} timesteps".format(t+1))
21
+ break
22
+ ```
23
+ ```plain
24
+ > python temp.py
25
+
26
+ [ 0.09110893 0.42872795 -0.14344982 -0.85604103]
27
+ [ 0.09968349 0.62548264 -0.16057064 -1.19017143]
28
+ [ 0.11219315 0.822279 -0.18437407 -1.52857381]
29
+ Episode finished after 17 timesteps
30
+
31
+ >
32
+ ```
33
+ ![イメージ説明](c5632621ae1632bf56fefc18b3f13d8d.png)