Movements
abses.space.move._Movements ¶
A class that handles actor movement in the simulation.
This class provides methods for moving actors between cells in the simulation grid. It handles basic movement operations like moving to specific coordinates, moving in directions, and random movement.
Attributes:
| Name | Type | Description |
|---|---|---|
actor |
The actor instance this movement handler belongs to. |
|
model |
The model instance this movement handler operates in. |
|
seed |
Unique identifier for the actor, used for random number generation. |
Source code in abses/space/move.py
to ¶
Move the actor to a specific location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to
|
PatchCell | Coordinate | Literal['random'] | None
|
The position to move to. If position is a Coordinate -a tuple of (row, col), it will be moved to the same layer. If pos is None, the actor will be removed from the world. |
None
|
indices
|
bool
|
The indices to move to. |
False
|
layer
|
Optional[PatchModule]
|
The layer where the actor is located. If layer is None, the actor will be moved to the same layer as the actor's current layer. |
None
|
indices
|
bool
|
Whether the position is indices. If indices is True, the position is indices. If indices is False, the position is position. |
False
|
Raises:
| Type | Description |
|---|---|
ABSESpyError
|
If the input layer is not consistent with the actor's layer. If the position is out of bounds. Or, if the pos is coordinate without layer. |
Source code in abses/space/move.py
off ¶
Remove the actor from the world.
Raises:
| Type | Description |
|---|---|
ABSESpyError
|
If the actor is not located on a cell, thus cannot move. |
Source code in abses/space/move.py
by ¶
Move the actor by a specific distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
MovingDirection
|
The direction to move. It should be a direction string such as: "left", "right", "up", "down", "up left", "up right", "down left", "down right". |
required |
distance
|
int
|
The distance to move toward the direction. |
1
|
Raises:
| Type | Description |
|---|---|
ABSESpyError
|
If the actor is not located on a cell, thus cannot move. |
ValueError
|
If the direction is invalid. |
Source code in abses/space/move.py
random ¶
Move the actor to a random location nearby.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prob
|
Optional[str]
|
The probability to select a cell. |
None
|
kwargs
|
Any
|
Passing keyword args to |
{}
|