I want to pass the destination node in which my agent is going to/is at as a string.

I have an agent (car) that has multiple parameters one of them being location. I have a resourcePool with multiple home locations in which the car can park (move to home of seized unit). I am trying to collect the node in which the car is parked at and pass it as a string to this location parameter as such when it exits the moveTo block:

if(moveTo.destinationNode(agent) == nodeA) {
    agent.location = "A";
} else {
    agent.location = "NULL";

However, when a car is parked on nodeA. I expect the value of location to be A, but the parameter comes up as NULL which it should not be. Any recommendation would be of great value. Thanks!

2 Answers

Community On

I think the problem is that you have used the == operator, but you have not overloaded it to compare two nodes. (I don't know how to do this, but you can). Maybe you can do something like if (x.location == y.location) {} (I'm making up these names). Hope this helps.

Community On

Issue Fixed:

if(agent.getNetworkNode() == nodeA){
   agent.location = "A"
} else if(agent.getNetworkNode() == nodeB){
   agent.location = "B"

... and so on