Skip to main content

Interactions between Entities

General Interactions

One of the most critical aspects of multi-agent system modeling and simulation is defining interaction mechanisms:

  • When modeling interactions between different entities, it's necessary to address the questions of "who to find" and "what to do" from the perspective of an entity.
Examples
  • A DeFi user Agent looks for a DEX Agent to trade a certain token.
  • A DeFi lending protocol Agent updates the collateral factor based on the price provided by the Oracle protocol Agent.
  • Celestial body C updates its motion state based on the states of celestial bodies A and B.
  • Each cell updates its next state based on the states of its neighbors.
  • The term "between different entities" encompasses interactions between individuals of different entity populations, between different individuals within the same population, between individuals and observers, and between observers of different entity populations.
  • Interaction methods include Finding Entities, Accessing Properties, and Calling Behaviors.
  • Since HoloBit uses a process to express entity behavior, all the following forms of interaction refer to modeling methods within the process.

Interactions Within the Same Population

  • An individual's behavior can directly call another behavior of its own.
  • An individual can directly access an observer's properties and call the observer's behaviors.
  • Neither an individual nor an observer can directly access the properties of other individuals in the same population or call their behaviors.
Tip

Interactions between individuals occur more frequently, both within the same population and across different populations. Please refer to the details below.

Interactions via the Ask Component

The Ask component is a tool used within an entity's behavioral process in modeling. It can get the entity object, access its properties, or trigger the other entity's behaviors.

Tip

"Ask" is the most frequently used interaction method, providing a powerful way to determine the target entity.

Ask to Find Entities

  • The Ask component is used to get the target entity, addressing the question of "which entity to find" from the perspective of the current entity. The default mode of the Ask component can be used for this purpose.
  • All three forms of the Ask component can be used to get the target entity object.
  • The obtained entity object can then be accessed in the calculation after the Ask action in the current process as This.Entity, or in the calculation of subsequent components as ask_component_name.Entity.

Ask to Access Properties

  • Accessing other entities' properties is equivalent to asking them for their properties, which can be done using the Ask component's access mode.

  • Only for accessing several properties of a single individual or observer.

  • Using the properties obtained

    The obtained properties can be added to the current canvas for graphical modeling by adding their quote objects, or they can be accessed in the calculation after the current process ask action as This.property_name or in the calculation formula of subsequent components as ask_component_name.property_name.

Tip

Strictly speaking, the 'ask' command can target any object, including the asker itself (using the 'Self' keyword). However, this tends to be overly complex and unnecessary, as both properties and behaviors can be directly accessed and called.

Ask to Call Behavior

  • An entity can ask another entity to execute its passive behavior. This can be accomplished by using the Ask component to call its behavior.
Examples in Web3
  • A DeFi trader asks Uniswap to trade a specified token, as illustrated in the diagram on the left.
  • The graphical modeling expression of asking to call in the Trader canvas is shown in the figure on the right.
  • It is equivalent to asking someone to do something.
Tip

Asking to call behavior is the most commonly used interaction method, especially when simulating a smart contract in the Web3 field. This is because a smart contract's execution is essentially "passive," depending on EOA accounts to initiate transactions.

  • The behavior of another entity can also be defined as a process of accessing property values. In this context, using the ask component to call behavior is akin to accessing the properties of the other entity.

Accessing Entity Properties Through Expressions

  • The properties of individual objects can be accessed in expressions using dot syntax.
  • Syntax format: entity_single_object``.property_name, where entity_single_object is limited to individuals or observers within an Entity population and cannot apply to [Entity].
Example

In the calculation of the process formula in entity A, you can use B_entity_object.Individuals.choice().property_name to access a certain property of a random individual of entity B.

Choice is a method of the List data type, used to select an element from a List randomly.

Specific Interactions Through Process Action Elements

Motion Interaction

  • Obviously, when an Agent moves within a Cell space, it involves the interaction between the two, such as the Cell will sense the Agent on it, and the Agent can locate the Cell space coordinates, etc.; their spatial relationship is detailed in the next section, Interactions in Cell Spaces.
  • Using the following process components, the interaction between the two can be easily implemented without having to consider the implementation details and focus on modeling.
    • The Move component is responsible for controlling the Agent's movement in space (such as moving forward, moving backward, turning, etc.).
    • The Place At component is responsible for setting the Agent's position in space.
  • Any entity can create new individuals of Agent or Link entities.
  • Just use the Create component in the behavior process.
  • The List of entity objects output by the Create component can be accessed by expressions.
  • Any entity can call the relevant built-in behaviors to destroy an entity, such as Agent_individual_object.Die and Link_Observer.RemoveNode.
  • Since individuals may be created and destroyed during the simulation process, the system will consider their real-time existence. For example, if there is a list L = Trader.individuals containing 100 individual objects, after the Die method of 10 individuals is called, they will be destroyed, and the output of len(L) will be 90, indicating the current number of entities. Any attempts to access the properties of, or call behaviors on, the destroyed entities will result in system errors.
  • When any entity is destroyed while the process execution is halfway through, the system will terminate its current process as the actor in real time.

Indirect Interaction Through Higher-Level Properties

For example, a trader made decisions by observing global price variables.

InteractionsBetweenEntities003.png

Indirect Interaction Through Conditional Start Events

Direct Interaction Through Messages

Note

As HoloBit advances, the methods of interaction between entities are expected to become more powerful and diverse.

Example

Model Example

Ask to Call Behaviors

Web3 users keep initiating transactions to DEX, causing token price changes.

Interactions in Cell Spaces

How Agents Interact with Cells in Spaces

  • This involves the interactions between Agents and Cells.

  • A Cell is the fundamental unit that constitutes the space in our model. Each cell is a square with a side length of 1, arranged in a grid-like pattern. The center of each cell has integer coordinates, representing the nominal coordinates of the individual cell, as indicated in the diagram below.

    InteractionsBetweenEntities004.png

  • An Agent's movement in a space is continuous and can be at any point within any Cell. This is represented by the X and Y coordinates in the Agent's built-in property Coordinates, which are both Float.

  • The current system regards the Agent as a point, so it can clearly define the Cell it occupies. A Cell also has no limitation on the number of Agents it can accommodate, even though an Agent might visually occupy more than one Cell due to its Size and Shape properties.

  • Although the Cell space range is limited, it can be set to wrap around horizontally, vertically, or both.

    • In wrap-around mode, once an Agent reaches the boundary, it will continue tomove and re-enter the space from the opposite boundary.
    • In non-wrapping mode, the Agent is forced to stop at the boundary, even if it has not completed its movement.
  • When an agent moves toward a corner,

    • If both horizontal and vertical boundaries are set to wrap, the agent will re-enter from the opposite corner if horizontal and vertical boundaries are set to wrap.
    • If either direction does not wrap, the agent will stop just before the corner, at the maximum feasible step it can take without crossing the boundary.
  • Agents can retrieve lists of neighboring agents or cells by specifying a radius using the methods GetNeighbors and GetNeighborCells, respectively.

Entity Representations in Worldview Charts

  • Entities are displayed in the Worldview Chart, which can represent a Physical World.
  • Cells serve as the background space, with their appearance controlled by built-in properties, such as Color.
  • Agents are shown as moving objects, with their styles controlled by built-in properties such as Shape Color, Size, etc.
  • Links are not visible in the Worldview Chart.

Example

Model Example

Wolf moving in the grasslands

  • This involves interactions between individuals from Agent and Link populations.
  • Imagine a Link as a handle connecting two Agents at either end to form a "dumbbell"; many such "dumbbells" establish a Link network.
  • Agents can follow the Links to find closely related individuals within such networks. This can be achieved either by using Ask components or by calling the built-in behavior GetRelatives of the Link observer.
  • Nodes or edges can be removed from the network without affecting the corresponding Agent entities. However, if a node Agent entity is destroyed, the associated Link entity will also be destroyed.

Entity Representations in Network Charts

  • Entities are displayed in the Network Chart.

  • Agents are represented as nodes, with their appearance controlled by built-in properties, such as Shape Color, Size, etc.

  • Links are shown as edges between nodes, and their appearance can be customized by properties such as LineType, Color, and Thickness.

  • Cells are not visible in the Network Chart.

    InteractionsBetweenEntities005.png

Example

Model Example

Accessing Closely Related Nodes in the Network Chart

Each network node obtains its degree of connection, i.e., the number of neighboring nodes. From the distribution, it can be observed that this is a Random Network.