def main(server, password): b = BDIAgent("slave_1@{}".format(server), password, "slave.asl") b.bdi.set_belief("master", "master@{}".format(server)) future = b.start() future.result() c = BDIAgent("slave_2@{}".format(server), password, "slave.asl") c.pause_bdi() future = c.start() future.result() a = MasterAgent("master@{}".format(server), password, "master.asl") a.bdi.set_belief("slave1", "slave_1@{}".format(server)) a.bdi.set_belief("slave2", "slave_2@{}".format(server)) a.bdi.set_belief('type', 'dec') future = a.start() future.result() time.sleep(5) print("Enabling BDI for slave2") c.set_asl("slave.asl") c.bdi.set_belief("master", "master@{}".format(server)) time.sleep(5) print("Disabling BDI for slave2") c.pause_bdi()
import argparse from spade_bdi.bdi import BDIAgent if __name__ == '__main__': parser = argparse.ArgumentParser( description='spade bdi master-server example') parser.add_argument('--server', type=str, default="localhost", help='XMPP server address.') parser.add_argument('--password', type=str, default="bdipassword", help='XMPP password for the agents.') args = parser.parse_args() a = BDIAgent("BDISenderAgent@" + args.server, args.password, "sender.asl") a.bdi.set_belief("receiver", "BDIReceiverAgent@" + args.server) a.start()