MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / windy_grid_penalized

Function windy_grid_penalized

rl/grid_world.py:265–333  ·  view source on GitHub ↗
(step_cost=-0.1)

Source from the content-addressed store, hash-verified

263
264
265def windy_grid_penalized(step_cost=-0.1):
266 g = WindyGrid(3, 4, (2, 0))
267 rewards = {
268 (0, 0): step_cost,
269 (0, 1): step_cost,
270 (0, 2): step_cost,
271 (1, 0): step_cost,
272 (1, 2): step_cost,
273 (2, 0): step_cost,
274 (2, 1): step_cost,
275 (2, 2): step_cost,
276 (2, 3): step_cost,
277 (0, 3): 1,
278 (1, 3): -1
279 }
280 actions = {
281 (0, 0): ('D', 'R'),
282 (0, 1): ('L', 'R'),
283 (0, 2): ('L', 'D', 'R'),
284 (1, 0): ('U', 'D'),
285 (1, 2): ('U', 'D', 'R'),
286 (2, 0): ('U', 'R'),
287 (2, 1): ('L', 'R'),
288 (2, 2): ('L', 'R', 'U'),
289 (2, 3): ('L', 'U'),
290 }
291
292 # p(s' | s, a) represented as:
293 # KEY: (s, a) --> VALUE: {s': p(s' | s, a)}
294 probs = {
295 ((2, 0), 'U'): {(1, 0): 1.0},
296 ((2, 0), 'D'): {(2, 0): 1.0},
297 ((2, 0), 'L'): {(2, 0): 1.0},
298 ((2, 0), 'R'): {(2, 1): 1.0},
299 ((1, 0), 'U'): {(0, 0): 1.0},
300 ((1, 0), 'D'): {(2, 0): 1.0},
301 ((1, 0), 'L'): {(1, 0): 1.0},
302 ((1, 0), 'R'): {(1, 0): 1.0},
303 ((0, 0), 'U'): {(0, 0): 1.0},
304 ((0, 0), 'D'): {(1, 0): 1.0},
305 ((0, 0), 'L'): {(0, 0): 1.0},
306 ((0, 0), 'R'): {(0, 1): 1.0},
307 ((0, 1), 'U'): {(0, 1): 1.0},
308 ((0, 1), 'D'): {(0, 1): 1.0},
309 ((0, 1), 'L'): {(0, 0): 1.0},
310 ((0, 1), 'R'): {(0, 2): 1.0},
311 ((0, 2), 'U'): {(0, 2): 1.0},
312 ((0, 2), 'D'): {(1, 2): 1.0},
313 ((0, 2), 'L'): {(0, 1): 1.0},
314 ((0, 2), 'R'): {(0, 3): 1.0},
315 ((2, 1), 'U'): {(2, 1): 1.0},
316 ((2, 1), 'D'): {(2, 1): 1.0},
317 ((2, 1), 'L'): {(2, 0): 1.0},
318 ((2, 1), 'R'): {(2, 2): 1.0},
319 ((2, 2), 'U'): {(1, 2): 1.0},
320 ((2, 2), 'D'): {(2, 2): 1.0},
321 ((2, 2), 'L'): {(2, 1): 1.0},
322 ((2, 2), 'R'): {(2, 3): 1.0},

Calls 2

setMethod · 0.95
WindyGridClass · 0.85

Tested by

no test coverage detected