grid_world_graph

safemdp.grid_world_graph(world_size)

Create a graph that represents a grid world.

In the grid world there are four actions, (1, 2, 3, 4), which correspond to going (up, right, down, left) in the x-y plane. The states are ordered so that np.arange(np.prod(world_size)).reshape(world_size) corresponds to a matrix where increasing the row index corresponds to the x direction in the graph, and increasing y index corresponds to the y direction.

Parameters:

world_size: tuple

The size of the grid world (rows, columns)

Returns:

graph: nx.DiGraph()

The directed graph representing the grid world.