Коммуникация интеллектуальных агентов
Пытаюсь реализовать МАС из 4х агентов, у первого есть путь к директории, который он должен отправить всем остальным. Проблема в том, что они не могут его принять. Отправитель:
def send_path_to_agents(self):
if self.path:
parser_content = KQMLList.from_string(f'(path "{str(self.path)}")')
parser_performative = KQMLPerformative('tell')
parser_performative.set('content', parser_content)
self.server.receive_request(None, parser_performative)
Получатель:
def receive_request(self, msg, content):
logging.info(f"Received message: {msg}")
logging.info(f"Content: {content}")
if isinstance(content.head(), str) and content.head().startswith('path'):
path = content.get(0).to_string()
self.parse_directory(path)
else:
reply_content = KQMLList()
reply_content.append('FAILURE')
reply_content.append(':reason')
reply_content.append('Invalid request')
reply_msg = KQMLPerformative('reply')
reply_msg.set('content', reply_content)
self.server.reply(None, reply_msg)
logging.warning("Invalid request received.")