GridWorld.add_path#

GridWorld.add_path(coord_from, coord_to, register_action=None)[source]#

Add a new inter-area connection.

Note

  • Creating a path within the same area is not allowed.

  • When an inter-area path from coord_from to coord_to with action register_action is built, a reverse path is also build at the same time, i.e. the agent can also move from coord_to to coord_from with the reverse action of register_action (e.g. the reverse action of UP(1, 0) is DOWN(-1, 0)).

Parameters:
  • coord_from (tuple of ints) – Coordinate of the path start state.

  • coord_to (tuple of ints) – Coordinate of the path end state.

  • register_action (tuple of ints (optional, default: None)) – Register an action to transport the agent from coord_from to coord_to. If None, possible action to register will be searched in the order of [UP(1, 0), DOWN(-1, 0), RIGHT(0, 1), LEFT(0, -1)], and the first possible action will be registered.

Examples

>>> W = GridWorld()
>>> W.add_area((2, 2))
>>> W.add_path((0, 0, 0), (1, 0, 0))
>>> W.add_area((3, 3))
>>> W.add_path((1, 1, 1), (2, 1, 0), register_action=(0, 1))