Closed ileacristian closed 6 years ago
I see a couple of things there.
First, you do not seem to send a request from the Coordinator, you need to do so like this:
def start_simulation(self):
for i in range(self.passive_agents_count):
agent = run_agent(str(i), base=Passive)
self.connect(agent.addr('coord'), alias='passive_%d' % i)
for i in range(0, self.steps):
self.current_step +=1
self.announce_agents_to_step()
for passive in range(self.passive_agents_count):
self.log_info('Asking agent %s for coords' % passive)
self.send('passive_%d' % passive, 'Give me coordinate!')
reply = self.recv('passive_%d' % passive)
print(reply)
self.send()
before receiving the reply.self.connect()
.Then you need to modify your giveCoord()
too:
def giveCoord(self, message):
self.log_info('Need to give coords')
return (self.x, self.y)
agent
parameter now, now self
is the agent itself. :blush:Haha. Thank you! I knew I was doing something silly. 😝
I want to use this method of communcation from this example: https://osbrain.readthedocs.io/en/stable/basic_patterns.html#request-reply But I want to do it in an OOP manner.
I have 2 types of agents: 1
Coordinator
and 20Passive
agents. I want theCoordinator
to ASK all thePassive
agents to give their coordinates.I'm probably doing something wrong 😰 because i get the following output:
And it hangs after this. 👆
Here is my code: