0
votes

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
What is nodeA? A String?GBlodgett
nodeA is a INode or pointnodeOscar Dyremyhr
If it isn't a primitive, then use .equals()GBlodgett

2 Answers

0
votes

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.

0
votes

Issue Fixed:

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

... and so on