MCPcopy Index your code
hub / github.com/rlcode/reinforcement-learning / step

Method step

1-grid-world/env.py:87–101  ·  view source on GitHub ↗
(self, action)

Source from the content-addressed store, hash-verified

85 return list(self.agent)
86
87 def step(self, action):
88 x, y = self.agent
89 if action == 0 and y > 0: y -= 1
90 elif action == 1 and y < HEIGHT - 1: y += 1
91 elif action == 2 and x > 0: x -= 1
92 elif action == 3 and x < WIDTH - 1: x += 1
93 self.agent = [x, y]
94 self.steps += 1
95 if self.agent == self.goal:
96 self.last_reward = 100
97 return list(self.agent), 100, True
98 if self.agent in self.obstacles:
99 self.last_reward = -100
100 return list(self.agent), -100, True
101 return list(self.agent), 0, False
102
103 def print_value_all(self, q_table):
104 self.q_overlay = q_table

Callers 12

train_modelMethod · 0.45
2-a2c.pyFile · 0.45
3-ppo.pyFile · 0.45
train_modelMethod · 0.45
1-dqn.pyFile · 0.45
run_test_loopFunction · 0.45
train_modelMethod · 0.45
6-reinforce.pyFile · 0.45
train_modelMethod · 0.45
5-deep_sarsa.pyFile · 0.45
4-q_learning.pyFile · 0.45
3-sarsa.pyFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected