-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq-learning.py
More file actions
31 lines (23 loc) · 771 Bytes
/
Copy pathq-learning.py
File metadata and controls
31 lines (23 loc) · 771 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
31
import gym
import numpy as np
env = gym.make("MountainCar-v0")
env.reset()
LEARNING_RATE = 0.1
#Discount - How important are future actions/rewards over current actions/rewards
DISCOUNT = 0.95
EPISODES = 25000
# print(env.observation_space.high)
# print(env.observation_space.low)
# print(env.action_space.n)
DISCRETE_OBSSPACE_SIZE = [20] * len(env.observation_space.high)
discrete_obsspace_win_size = (env.observation_space.high - env.observation_space.low) / DISCRETE_OBSSPACE_SIZE
q_table = np.random.uniform(low=-2, high=0, size=(DISCRETE_OBSSPACE_SIZE + [env.action_space.n]))
# print(q_table)
# print(q_table.shape)
done = False
while not done:
action = 2
new_state, reward, done, _ = env.step(action)
# print(reward, new_state)
env.render()
env.close()