Movement

Methods

move(distance)

Token.move(distance: int = 0)[source]

Moves actor distance steps in current direction

../_images/move1.png
Parameters

distance – Number of steps to move. If distance = 0, the actor speed will be used.

Returns

The moved token

Examples

if sensing_on_board, move forward:

>>> class Robot(Token):
>>>    def act(self):
>>>         if self.sensing_on_board():
>>>             self.move()

move_back()

Token.move_back()[source]

“Undo” the last move. Moves the actor to the last position and resets direction.

../_images/move_back1.png
Returns

The moved token

Examples

move_back when field is blocked:

>>>  def on_sensing_wall(self, wall):
>>>    self.move_back()

move_in_direction(direction)

Token.move_in_direction(direction: Union[int, str], distance=1)[source]

Moves token distance steps into a direction.

../_images/move_in_direction1.png
Options
  • 0, “up” - Look up

  • 90, “right”, - Look right

  • -90, “left”, - Look left

  • -180, 180, “down” - Look down

../_images/direction2.png
Parameters

direction – Direction as angle

Returns

The token itself

move_to(position)

Token.move_to(position: miniworldmaker.board_positions.board_position.BoardPosition)[source]

Moves token distance to a specific board_posiition

Parameters
  • position – The position to which the actor should move. The position can be a 2-tuple (x, y)

  • will be converted to a board_position (which) –

../_images/move_to1.png
Returns

The token itself

Examples:

move to (3, 2) on mouse_click

>>> def on_clicked_left(self, position):
>>>   self.move_to((3,2))