-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
30 lines (23 loc) · 658 Bytes
/
test.py
File metadata and controls
30 lines (23 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import torch
import gym
from torch import nn, optim
import random
import collections
import numpy as np
if __name__ == "__main__":
MAX_EPOCH = 10000
env = gym.make('Pendulum-v0')
env.seed(0)
# print('State shape:', env.observation_space.shape)
# print('Number of actions:', env.action_space.n)
state = env.reset()
for epo_i in range(MAX_EPOCH):
state = env.reset()
done = False
while not done:
action = [random.uniform(-2, 2)]
env.render()
state, reward, done, info = env.step(action)
if done:
break
env.close()