MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / get_next_state

Method get_next_state

rl/grid_world.py:43–57  ·  view source on GitHub ↗
(self, s, a)

Source from the content-addressed store, hash-verified

41 return (self.i, self.j)
42
43 def get_next_state(self, s, a):
44 # this answers: where would I end up if I perform action 'a' in state 's'?
45 i, j = s[0], s[1]
46
47 # if this action moves you somewhere else, then it will be in this dictionary
48 if a in self.actions[(i, j)]:
49 if a == 'U':
50 i -= 1
51 elif a == 'D':
52 i += 1
53 elif a == 'R':
54 j += 1
55 elif a == 'L':
56 j -= 1
57 return i, j
58
59 def move(self, action):
60 # check if legal move first

Calls

no outgoing calls

Tested by

no test coverage detected