1
votes

I am trying to make agents move through navigational nodes. This is my setup:

  1. Agents (let's say people/person) are located randomly into space.
  2. Nodes (just another kind of agent) are also located randomly into space.
  3. Each person defines a target node. A person should move to that target node through navigational nodes.

This is what I want to do:

  1. Each agent rotates toward a target node.
  2. Each agent has a vision range that would increase if the agent doesn't find any navigational node where to move.

  1. Each agent moves to the closest navigational node, and starts the searching process again.

  2. The agent stops when the closest navigational node is the target node. Then, the agent has arrived!

My questions:

  1. I set the rotation of an agent using:

     double r = Math.atan2( targetNode.getY() - this.getY(),
            targetNode.getX() - this.getX());
    
     this.setRotation(r);
    
  2. I am not sure how to program the vision range in Anylogic. Any ideas?

1

1 Answers

1
votes

I did a similar thing during my PhD.

Add a polygonal node object myViewArea to your agent with the initial size and shape of the view area.

Then, you can let the agent check if he "sees" a navi node by using the myViewArea.contains() method and checking that against all navi nodes in the model.

If he doesn't find any, you can change your myViewArea programmatically (see Java API for that)

Hope this helps.