Overview
Agent Interactions
Interactions from params.classes.bond_types.acts_allowed
are implemented in standalone files that implement the interface from interactions.BaseInteraction
. This allows for the logic related to an interaction type to be consolidated into one place and make incorporating a new interaction type as simple as possible.
To add a new interaction:
- Add the param to
param.classes.bond_types.acts_allowed
- Add a file to
interactions/
which creates a class that is a sub-class ofBaseInteraction
- Implement the methods of
BaseInteraction
which are needed for this interaction - Not all methods are needed for all interactions (see below for details on the methods)
- Implement the methods of
- Re-export the feature from
interactions/__init__.py
- Add tests in
tests/interactions/
- Add it to the docs in
docs/api/interactions/
and to the nav inmkdocs.yml
The TITAN
class uses sub-classes of BaseInteraction
to initialize the object/call methods as appropriate.
BaseInteraction
Source code in titan/interactions/base_interaction.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
name: str = ''
class-attribute
instance-attribute
Name of interaction in the params file.
interact(model, rel)
classmethod
Given a model and a relation, have the agents in the relationship interact for a time step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
TITAN
|
The running model |
required |
rel |
Relationship
|
The relationship where interaction is happening |
required |
Source code in titan/interactions/base_interaction.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|