0
votes

I have a population of "passengers" agents in which every single agent of this population makes a request ("OrderPassenger" agent type ) to another "Airport" agent. The "Airport" agent, at this point, must respond to the request through an "AirportSuggestion" agent and send it to the specific "Passenger" of the "passengers" population.

I tried to use: send (airportSuggestion, main.passengers (orderPassenger.passenger)); but orderPassenger.passenger is not an integer type.

I tried to use: send (airportSuggestion, main.passengers (0)); but it is not said that the passenger (0) is the one who made the request.

What is the method to select that specific agent who made that specific request to the "Airport" agent?

Does an agent of a population of agents have an id number to identify it?

1

1 Answers

0
votes

The easiest way is to make your Passenger agent the message that is being sent around.

So Passenger sends itself to Airport using send(this, someAirport). Airport does it's thing and memorizes the passenger from the message using a local variable or directly in the "on message received" code box where the passenger is accesible using the "sender" keyword (check out how those work here).

cheers