MCPcopy Create free account
hub / github.com/rlcode/reinforcement-learning / learn

Method learn

1-grid-world/4-q_learning.py:17–21  ·  view source on GitHub ↗
(self, state, action, reward, next_state)

Source from the content-addressed store, hash-verified

15
16 # update q function with sample <s, a, r, s'>
17 def learn(self, state, action, reward, next_state):
18 current_q = self.q_table[state][action]
19 # using Bellman Optimality Equation to update q function
20 new_q = reward + self.discount_factor * max(self.q_table[next_state])
21 self.q_table[state][action] += self.learning_rate * (new_q - current_q)
22
23 # get action for the state according to the q function table
24 # agent pick action of epsilon-greedy policy

Callers 1

4-q_learning.pyFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected