Created
June 3, 2018 09:03
-
-
Save pyliaorachel/d0827a23828f925c49cea0100bcd4cf6 to your computer and use it in GitHub Desktop.
OpenAI Gym CartPole - Q table (choose action)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def choose_action(state, q_table, action_space, epsilon): | |
| if np.random.random_sample() < epsilon: # 有 ε 的機率會選擇隨機 action | |
| return action_space.sample() | |
| else: # 其他時間根據現有 policy 選擇 action,也就是在 Q table 裡目前 state 中,選擇擁有最大 Q value 的 action | |
| return np.argmax(q_table[state]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment