(self, s, a, G, gamma, lambda_)
| 60 | return result |
| 61 | |
| 62 | def update(self, s, a, G, gamma, lambda_): |
| 63 | X = self.feature_transformer.transform([s]) |
| 64 | # assert(len(X.shape) == 2) |
| 65 | |
| 66 | # slower |
| 67 | # for action in range(self.env.action_space.n): |
| 68 | # if action != a: |
| 69 | # self.eligibilities[action] *= gamma*lambda_ |
| 70 | # else: |
| 71 | # self.eligibilities[a] = grad + gamma*lambda_*self.eligibilities[a] |
| 72 | |
| 73 | self.eligibilities *= gamma*lambda_ |
| 74 | self.eligibilities[a] += X[0] |
| 75 | self.models[a].partial_fit(X[0], G, self.eligibilities[a]) |
| 76 | |
| 77 | def sample_action(self, s, eps): |
| 78 | if np.random.random() < eps: |
no test coverage detected