(self, action)
| 57 | return i, j |
| 58 | |
| 59 | def move(self, action): |
| 60 | # check if legal move first |
| 61 | if action in self.actions[(self.i, self.j)]: |
| 62 | if action == 'U': |
| 63 | self.i -= 1 |
| 64 | elif action == 'D': |
| 65 | self.i += 1 |
| 66 | elif action == 'R': |
| 67 | self.j += 1 |
| 68 | elif action == 'L': |
| 69 | self.j -= 1 |
| 70 | # return a reward (if any) |
| 71 | return self.rewards.get((self.i, self.j), 0) |
| 72 | |
| 73 | def undo_move(self, action): |
| 74 | # these are the opposite of what U/D/L/R should normally do |
no test coverage detected