0
votes

I am trying to force agents of a population to exchange messages in AnyLogic. I would like each time agent A sends a message to B the icon of the message to move from A to B. How can I implement this?

2

2 Answers

1
votes

The code Emile sent you works to move an agent from one place to another one. I understand you don't want to move your two agents, but instead you want to move only a "message icon" from one to the other. For that you can create an agent (let's call it agent "Message"), create it and locate it in the agentA, and tell it (as Emile said) to move to agentB: messageAB.moveTo(agentB.getPosition()); this way you'll get the effect you want. You could also:

  1. use a timer to move from one place to another, or
  2. use an event and change the position of the icon dinamically depending on how much time you have remaining on that event
  3. use a source/delay/sink for the same as in point 2
0
votes

There are basically two ways to move an agent:

  1. Jump to agent B: Instantly appears near agent B
  2. Move to agent A at a certain speed

For each one the code is respectively as follows:

agentA.jumpTo( agentB.getXYZ() );

agentA.moveTo( agentB );

Where agentA and agentB refer to the agents which you might call differently depending where you are in the model.