model.agent module¶
Module that holds classes that represent agents.
-
class
model.agent.Agent¶ Bases:
model.entity.EntityClass that represents an agent.
-
add_motivations(motivation)¶
-
add_primitives(primitives)¶
-
collidable()¶
-
color= (3, 124, 146, 255)¶
-
enacted_interaction(interaction, data)¶ Tell the agent which primitive interaction was actually enacted.
Parameters: - interaction – The primitive interaction that was actually enacted.
- data – The data that was (optionally) returned by prepare_interaction this step.
-
get_interaction_memory()¶
-
get_name()¶ Get this agent’s name
Returns: This agent’s name
-
get_perception(world)¶
-
has_perception_handler()¶
-
prepare_interaction()¶ Prepare an interaction to enact.
Interaction enaction is split into two parts to better handle multiple agents. First, all agents prepare the interaction to enact without manipulating the world state, and afterwards all these interactions are enacted (in randomized order). The world notifies the agent of which interaction was actually enacted.
This ensures that an agent does not have access to world state information it should not yet know at any point in time (especially when it becomes more complex with e.g. a visual subsystem). If preparation was immediately followed by enaction, an agent could potentially respond to the interaction of another agent made “earlier” at the same discrete point in time!
Returns: The primitive interaction that is to be enacted and optionally something that will be passed to enacted_interaction of this agent.
-
set_interaction_memory(interaction_memory)¶
-
set_perception_handler(perception_handler)¶
-
setup_interaction_memory()¶ Setup the interaction memory of this agent.
-
to_json()¶
-
-
class
model.agent.ConstructiveAgent¶ Bases:
model.agent.AgentAn agent with a fully recursive existence. It considers all experiment as abstract and processes all experiments in the same way.
-
activate_interactions()¶ Step 1 of the sequential system.
Known composite interactions whose pre-interaction belongs to the context are activated.
-
consider_alternative_interactions()¶ Add-on to the sequential system, between steps 2 and 3.
Proposed post-interactions are scrutinized by looking at alternative interactions that have occurred when trying to activate that interaction. If the alternative interaction itself is also proposed, the context indicates the alternative is likely to occur. Thus, the agent anticipates that the alternative might happen instead of the intended interaction. The intended interaction’s proclivity is temporarily adjusted to reflect this.
-
enacted_interaction(interaction_, data)¶
-
prepare_interaction()¶
-
propose_interactions()¶ Step 2 of the sequential system.
Post-interactions of activated interactions are proposed together with the weight of the activation interaction (as a tuple).
-
select_intended_interaction()¶ Step 3 of the sequential system.
The decisional mechanism; choose an interaction to enact (primitive or composite).
The intended interaction is selected from the proposed interactions based on the weight of the activated interactions and the values of the proposed post interactions.
-
update_context(enacted_interaction, learned_or_reinforced)¶ Step 6 of the sequential system.
Add all learned / reinforced interactions to the context.
Parameters: - enacted_interaction – The interaction that was enacted (can be different from the intended interaction)
- learned_or_reinforced – A list of interactions that were just learned or reinforced.
-
-
class
model.agent.HomeostaticConstructiveAgent¶ Bases:
model.agent.ConstructiveAgentA homeostatic agent is a constructive agent where valences of interactions are a function of internal energy levels of the agent (these homeostatic values are not directly observable by the agent).
-
add_to_homeostatic_value(homeostatic_property, delta_value)¶
-
get_homeostatic_value(homeostatic_property)¶
-
set_homeostatic_value(homeostatic_property, value)¶
-
setup_interaction_memory()¶
-
-
class
model.agent.HumanAgent¶ Bases:
model.agent.AgentAn agent that is controlled by the user.
-
choose_from_list()¶ Method to choose interaction from a list of all interactions known by this agent.
-
color= (146, 124, 3, 255)¶
-
enacted_interaction(interaction, data)¶
-
get_interaction_from_input()¶ Get the interaction the agent should enact from user input
-
prepare_interaction()¶
-
-
class
model.agent.ProgrammableAgent(program=None)¶ Bases:
model.agent.AgentAn agent that can be programmed (with prior knowledge) to interact with the world.
-
color= (111, 3, 146, 255)¶
-
enacted_interaction(interaction, data)¶
-
prepare_interaction()¶
-
set_program(program)¶ Set the programmable agent’s program.
-
-
class
model.agent.SimpleAgent¶ Bases:
model.agent.AgentAn agent with a simple existence.
-
anticipate()¶ Anticipate the possible interactions based on the current context.
Returns: A list of possible (primitive) interactions.
-
enacted= None¶
-
enacted_interaction(interaction, data)¶
-
learn_composite_interaction(context, enacted)¶ Learn a composite interaction or reinforce it if it is already known.
Parameters: - context – The context (pre-interaction).
- enacted – The newly enecated interaction (post-interaction).
-
prepare_interaction()¶
-
select_experiment(anticipations)¶ Select the best interaction from a list of anticipated interactions.
If the list of anticipated interactions is empty or if the best interaction has negative valence, return a random primitive interaction.
Parameters: anticipations – The list of interactions to choose an experiment from. Returns: A chosen primitive interaction.
-