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

Function grid_5x5

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

Source from the content-addressed store, hash-verified

335
336
337def grid_5x5(step_cost=-0.1):
338 g = Grid(5, 5, (4, 0))
339 rewards = {(0, 4): 1, (1, 4): -1}
340 actions = {
341 (0, 0): ('D', 'R'),
342 (0, 1): ('L', 'R'),
343 (0, 2): ('L', 'R'),
344 (0, 3): ('L', 'D', 'R'),
345 (1, 0): ('U', 'D', 'R'),
346 (1, 1): ('U', 'D', 'L'),
347 (1, 3): ('U', 'D', 'R'),
348 (2, 0): ('U', 'D', 'R'),
349 (2, 1): ('U', 'L', 'R'),
350 (2, 2): ('L', 'R', 'D'),
351 (2, 3): ('L', 'R', 'U'),
352 (2, 4): ('L', 'U', 'D'),
353 (3, 0): ('U', 'D'),
354 (3, 2): ('U', 'D'),
355 (3, 4): ('U', 'D'),
356 (4, 0): ('U', 'R'),
357 (4, 1): ('L', 'R'),
358 (4, 2): ('L', 'R', 'U'),
359 (4, 3): ('L', 'R'),
360 (4, 4): ('L', 'U'),
361 }
362 g.set(rewards, actions)
363
364 # non-terminal states
365 visitable_states = actions.keys()
366 for s in visitable_states:
367 g.rewards[s] = step_cost
368
369 return g
370

Callers

nothing calls this directly

Calls 2

setMethod · 0.95
GridClass · 0.85

Tested by

no test coverage detected