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_fromtocoord_towith actionregister_actionis built, a reverse path is also build at the same time, i.e. the agent can also move fromcoord_totocoord_fromwith the reverse action ofregister_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_fromtocoord_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))