Actor (Agent)
Bases: GeoAgent
, _BaseObj
, _LinkNodeActor
An actor in a social-ecological system (or "Agent" in an agent-based model.)
Attributes:
Name | Type | Description |
---|---|---|
breed |
The breed of this actor (by default, class name). |
|
layer |
Optional[PatchModule]
|
The layer where the actor is located. |
indices |
Optional[PatchModule]
|
The indices of the cell where the actor is located. |
pos |
Optional[Pos]
|
The position of the cell where the actor is located. |
on_earth |
bool
|
Whether the actor is standing on a cell. |
at |
PatchCell | None
|
The cell where the actor is located. |
link |
PatchCell | None
|
The link manipulating proxy. |
move |
_Movements
|
The movement manipulating proxy. |
Methods:
Name | Description |
---|---|
get |
Gets the value of an attribute from the actor or its cell. |
set |
Sets the value of an attribute on the actor or its cell. |
die |
Kills the actor. |
Source code in abses/actor.py
move
cached
property
¶
A proxy for manipulating actor's location.
move.to()
: moves the actor to another cell.move.off()
: removes the actor from the current layer.move.by()
: moves the actor by a distance.move.random()
: moves the actor to a random cell.
age ¶
get ¶
Gets attribute value from target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr |
str
|
The name of the attribute to get. |
required |
target |
Optional[TargetName]
|
The target to get the attribute from. If None, the agent itself is the target. If the target is an agent, get the attribute from the agent. If the target is a cell, get the attribute from the cell. |
None
|
Returns:
Type | Description |
---|---|
Any
|
The value of the attribute. |
Source code in abses/actor.py
set ¶
Sets the value of an attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr |
str
|
The name of the attribute to set. |
required |
value |
Any
|
The value to set the attribute to. |
required |
target |
Optional[TargetName]
|
The target to set the attribute on. If None, the agent itself is the target. 1. If the target is an agent, set the attribute on the agent. 2. If the target is a cell, set the attribute on the cell. |
None
|
Raises:
Type | Description |
---|---|
TypeError
|
If the attribute is not a string. |
ABSESpyError
|
If the attribute is protected. |
Source code in abses/actor.py
die ¶
Kills the agent (self)
setup ¶
moving ¶
Overwrite this method. It should be called when the actor is moved. The return value is whether the actor can move to the cell.
Either select the agent according to specified criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selection |
Union[str, Dict[str, Any]]
|
Either a string or a dictionary of key-value pairs. Each represents agent attributes to be checked against. |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether the agent is selected or not |