API Reference
RxEnvironments.AbstractEntity — TypeAbstractEntity{T}The AbstractEntity type supertypes all entities. It describes basic functionality all entities should have. It is assumed that every entity has a markov blanket, which has actuators and sensors. The AbstractEntity also has a field that describes whether or not the entity is terminated.
RxEnvironments.RxEntity — TypeRxEntityThe RxEntity is the vanilla implementation of an AbstractEntity that is used in most cases. It is a wrapper around an entity that adds the following functionality:
- A
MarkovBlanketthat contains the actuators and sensors of the entity - A
EntityPropertiesthat contains the state space, whether or not the entity is active, and the real time factor - A
EntityActorthat handles the logic for receiving observations and sending actions
Rocket.on_next! — MethodRocket.on_next!(actor::EntityActor{ActiveEntity}, observation)})Handles the logic for an incoming observation for an active entity. This means that the entity will update its state, incorporate the observation into its state, and then send an action to all of its subscribers. The action is determined by the what_to_send function. Emissions can be filtered by implementing the emits function.
This function is automatically called whenever the entity receives an observation on it's sensor. The observation will contain the data sent by the emitter as well as a reference to the emitter itself.
Rocket.on_next! — MethodRocket.on_next!(actor::EntityActor{PassiveEntity}, observation)Handles the logic for an incoming observation for a passive entity. This means that we will only incorporate the observation into the entity's state.
Rocket.unsubscribe! — MethodUnsubscribes receiver from emitter. Any data sent from emitter to receiver will not be received by receiver after this function is called.
RxEnvironments.__send! — Method__send!(recipient::AbstractEntity, emitter::AbstractEntity, action::Any)Send an action from emitter to recipient.
RxEnvironments.action_type — Methodaction_type(::T)Returns the default action type for an entity of type T. By default, this function returns Any. This is used to determine the type of actions that can be sent to an entity. Although this restricts the type of actions that can be sent to an entity, it allows for more type-stable code.
RxEnvironments.add! — Methodadd!(first::AbstractEntity{T,S,E}, second; environment=false) where {T,S,E}Adds second to first. If environment is true, the AbstractEntity created for second will be labeled as an environment. The Markov Blankets for both entities will be subscribed to each other.
Arguments
first::AbstractEntity{T,S,E}: The entity to whichsecondwill be added.second: The entity to be added tofirst.is_active=false: A boolean indicating whethersecondshould be instantiated as an active entity.
RxEnvironments.create_entity — Methodcreate_entity(entity; is_discrete = false, is_active = false, real_time_factor = 1)Creates an RxEntity that decorates a given entity. The is_discrete and is_active parameters determine whether or not the entity lives in a discrete or continuous state-space, and whether or not the entity is active or passive. The real_time_factor parameter determines how fast the entity's clock ticks. This function can be used as a lower-level API in order to create a more complex network of entities.
RxEnvironments.emits — Methodemits(subject, listener, observation)Determines if an entity of the type of subject should emit an observation to an entity of the type of listener when presented with an obervation of type observation. Users should implement this function for their own entity and observation types to handle the logic of when to emit observations to which entities. By default, this function returns true.
RxEnvironments.is_subscribed — Methodis_subscribed(subject::AbstractEntity, target::AbstractEntity)Check if subject is subscribed to target.
Arguments
subject::AbstractEntity: The entity that may be subscribed totarget.target::AbstractEntity: The entity that may be subscribed to bysubject.
Returns
true if subject is subscribed to target, false otherwise.
RxEnvironments.receive! — Methodreceive!(recipient::AbstractEntity, emitter::AbstractEntity, observation::Any)Receive an observation from emitter and update the state of recipient accordingly.
See also: RxEnvironments.send!
RxEnvironments.send! — Methodsend!(recipient::AbstractEntity, emitter::AbstractEntity, action::Any)Send an action from emitter to recipient.
RxEnvironments.subscribe_to_observations! — Methodsubscribe_to_observations!(entity::AbstractEntity, actor)Subscribe actor to the observations of entity. Any data sent to entity will be received by actor after this function is called.
RxEnvironments.terminate! — Methodterminate!(entity::AbstractEntity)Terminate an entity by setting its is_terminated flag to true and severing off all subscriptions to and from the entity.
Arguments
entity::AbstractEntity: The entity to terminate.
RxEnvironments.time_interval — Methodtime_interval(::T)Returns the default time interval for an entity of type T. By default, this function returns 1. This is used in discrete active entities to determine the elapsed time between state updates. Through dispatching, we can define different time intervals for different entity types.
RxEnvironments.update! — Methodupdate!(e::AbstractEntity{T,ContinuousEntity,E}) where {T,E}Update the state of the entity e based on its current state and the time elapsed since the last update. Acts as state transition function.
Arguments
e::AbstractEntity{T,ContinuousEntity,E}: The entity to update.