How to use the spade.Behaviour.MessageTemplate function in spade

To help you get started, we’ve selected a few spade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github javipalanca / spade / examples / unittests / p2pTestCase.py View on Github external
def testSendMsgP2PPY(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(p2pRecvMsgBehav("p2ppy"),t)
        self.a.addBehaviour(p2pSendMsgBehav("p2ppy"),None)
        counter = 0
        while self.b.msg == None and counter < 10:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.b.msg,None)
        self.assertEqual(self.b.msg.getContent(),"testSendMsg")
        self.assertEqual(self.b.msg.getSender(), self.Aaid)
        self.assertEqual(len(self.b.msg.getReceivers()),1)
        self.assertEqual(self.b.msg.getReceivers()[0], self.Baid)
        self.assertEqual(self.b.msg._attrs["method"],"p2ppy")
github javipalanca / spade / examples / unittests / basicTestCase.py View on Github external
def testSendMsg(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(RecvMsgBehav(),t)
        self.a.addBehaviour(SendMsgBehav(),None)
        counter = 0
        while self.b.msg == None and counter < 10:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.b.msg,None)
        self.assertEqual(self.b.msg.getContent(),"testSendMsg")
        self.assertEqual(self.b.msg.getSender(), self.Aaid)
        self.assertEqual(len(self.b.msg.getReceivers()),1)
        self.assertEqual(self.b.msg.getReceivers()[0], self.Baid)
github javipalanca / spade / examples / unittests / basicTestCase.py View on Github external
def testSendAndRecvMsg(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(AnswerMsgBehav(),t)
        template.setSender(self.Baid)
        t = spade.Behaviour.MessageTemplate(template)
        self.a.addBehaviour(SendAndRecvMsgBehav(),t)
        counter = 0
        while self.a.msg == None and counter < 20:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.a.msg,None)
        self.assertEqual(self.a.msg.getContent(),"testSendAndRecvMsg")
github javipalanca / spade / examples / unittests / p2pTestCase.py View on Github external
def testSendAndRecvMsgP2PPY(self):
        template = spade.Behaviour.ACLTemplate()
        template.setSender(self.Aaid)
        t = spade.Behaviour.MessageTemplate(template)
        self.b.addBehaviour(p2pAnswerMsgBehav("p2ppy"),t)
        template.setSender(self.Baid)
        t = spade.Behaviour.MessageTemplate(template)
        self.a.addBehaviour(p2pSendAndRecvMsgBehav("p2ppy"),t)
        counter = 0
        while self.a.msg == None and counter < 20:
            time.sleep(1)
            counter += 1
        self.assertNotEqual(self.a.msg,None)
        self.assertEqual(self.a.msg.getContent(),"testSendAndRecvMsg")
        self.assertEqual(self.a.msg._attrs["method"],"p2ppy")
github javipalanca / spade / examples / dalmuti / jugador.py View on Github external
template.setOntology("Dalmuti")
        template.setPerformative("request")
        template.setConversationId("Inicio")
        mt = spade.Behaviour.MessageTemplate(template)
        # Comportamiento inicial
        self.addBehaviour(self.inicioBehav(), mt)

        template.setPerformative( "refuse" )
        template.setConversationId("FIN")
        mt = spade.Behaviour.MessageTemplate(template)
        # Comportamiento de cerrar la conexion
        self.addBehaviour(self.cerrarBehav(), mt)

        template.setPerformative( "inform" )
        template.setConversationId("Tirada")
        mt = spade.Behaviour.MessageTemplate(template)
        # Comportamiento de actualizar la tirada en la mesa
        self.addBehaviour(self.tiradaMesaBehav(), mt)

        template.setPerformative( "inform" )
        template.setConversationId("Carta")
        mt = spade.Behaviour.MessageTemplate(template)
        # Comportamiento de actualizar la tirada en la mesa
        self.addBehaviour(self.recibirCartasBehav(), mt)

        template.setPerformative( "request" )
        template.setConversationId("Tira")
        mt = spade.Behaviour.MessageTemplate(template)
        # Comportamiento tirar en nuestro turno
        self.addBehaviour(self.tirarBehav(), mt)

        template.setPerformative( "inform" )
github javipalanca / spade / examples / benchmark / bench1_receiver.py View on Github external
def _setup(self):
            temp = spade.Behaviour.ACLTemplate()
            temp.setPerformative("request")
	    t = spade.Behaviour.MessageTemplate(spade.Behaviour.ACLTemplate())
	    self.addBehaviour(self.behav(),t)
github javipalanca / spade / examples / dalmuti / gameManager.py View on Github external
def partida(self):
        #Empieza una partida indefinidamente

        template = spade.Behaviour.ACLTemplate()
        template.setOntology("Dalmuti")
        template.setPerformative("inform")
        template.setConversationId("Tiro")        
        mt = spade.Behaviour.MessageTemplate(template)

        self.addBehaviour(self.partidaBehav(), mt)

        template.setPerformative("inform")
        template.setConversationId("Salgo")
        mt = spade.Behaviour.MessageTemplate(template)
        # Anotamos los jugadores que van saliendo
        self.addBehaviour(self.saliendoBehav(), mt)