()
| 97 | |
| 98 | |
| 99 | def standard_grid(): |
| 100 | # define a grid that describes the reward for arriving at each state |
| 101 | # and possible actions at each state |
| 102 | # the grid looks like this |
| 103 | # x means you can't go there |
| 104 | # s means start position |
| 105 | # number means reward at that state |
| 106 | # . . . 1 |
| 107 | # . x . -1 |
| 108 | # s . . . |
| 109 | g = Grid(3, 4, (2, 0)) |
| 110 | rewards = {(0, 3): 1, (1, 3): -1} |
| 111 | actions = { |
| 112 | (0, 0): ('D', 'R'), |
| 113 | (0, 1): ('L', 'R'), |
| 114 | (0, 2): ('L', 'D', 'R'), |
| 115 | (1, 0): ('U', 'D'), |
| 116 | (1, 2): ('U', 'D', 'R'), |
| 117 | (2, 0): ('U', 'R'), |
| 118 | (2, 1): ('L', 'R'), |
| 119 | (2, 2): ('L', 'R', 'U'), |
| 120 | (2, 3): ('L', 'U'), |
| 121 | } |
| 122 | g.set(rewards, actions) |
| 123 | return g |
| 124 | |
| 125 | |
| 126 | def negative_grid(step_cost=-0.1): |
no test coverage detected