Skip to content

Commit

Permalink
more intuitive solution
Browse files Browse the repository at this point in the history
  • Loading branch information
chucklqsun committed Jan 27, 2018
1 parent 0cc226c commit f677ef2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def build_q_table(n_states, actions):
def choose_action(state, q_table):
# This is how to choose an action
state_actions = q_table.iloc[state, :]
if (np.random.uniform() > EPSILON) or (not state_actions.any()): # act non-greedy or state-action have no value
if (np.random.uniform() > EPSILON) or ((state_actions == 0).all()): # act non-greedy or state-action have no value
action_name = np.random.choice(ACTIONS)
else: # act greedy
action_name = state_actions.idxmax() # replace argmax to idxmax as argmax means a different function in newer version of pandas
Expand Down

0 comments on commit f677ef2

Please sign in to comment.