GridWorld.step#

GridWorld.step(action)[source]#

Make the agent move toward direction given by action.

Note

  • If one movement will cause the agent get out of the world, the agent will be forced to stay in the same position (state) instead.

  • If the agent reaches a state with an object, no matter whether the agent gets a reward or punishment from the object, this trial will end and the agent will be transported back to its initial state.

Parameters:

action (tuple of ints {(0, 0), (1, 0), (-1, 0), (0, 1), (0, -1)}) – Direction of the agent movement.

Returns:

  • next_state (tuple of ints) – Next state of the agent after movement.

  • reward (int or float) – Reward that the agent gets at through this movement.

  • done (bool) – Whether this trial ends.

Examples

>>> W = GridWorld()
>>> W.add_area((2, 3))
>>> W.add_path((0, 0, 0), (1, 0, 0))
>>> W.init_agent()
>>> W.step((1, 0))
((1, 0, 0), 0.0, False)