Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# En este punto habra empezado
print nombreAgente+": Ok!! A ver si hay suerte..."
# Escogemos una carta al azar para establecer los
# roles iniciales de la partida
lim = string.atoi(self.msg.getContent())
carta = random.randint(0, lim-1)
print nombreAgente+": Elijo la carta "+str(carta)
#Enviamos nuestra eleccion
self.myAgent.send2game("request", "Carta", str(carta))
class cerrarBehav(spade.Behaviour.OneShotBehaviour):
def _process(self):
self.msg = None
self.msg = self._receive(True)
print nombreAgente+": Bye!!"
self.myAgent._kill()
class impuestosBehav(spade.Behaviour.Behaviour):
def _process(self):
self.msg = None
mA = self.myAgent
self.msg = self._receive(True)
rol, cont = string.split(self.msg.getContent())
import os
import sys
sys.path.append('..'+os.sep+'trunk')
sys.path.append('..')
import spade
class TravelAgent(spade.Agent.Agent):
class MyBehav(spade.Behaviour.OneShotBehaviour):
def onStart(self):
print "Starting behaviour . . ."
def _process(self):
# Show platform info
pi = self.myAgent.getPlatformInfo()
print pi
# Set the receiver data
receiver = spade.AID.aid(name="OMS@clapton:1099/JADE",
addresses=["http://clapton.dsic.upv.es:7778/acc"])
# Build the message to register in THOMAS
self.msg = spade.ACLMessage.ACLMessage() # Instantiate the message
#self.msg.setPerformative("inform") # Set the "request" FIPA performative
self.msg.addReceiver(receiver) # Add the message receiver
#####################################
'''
This file shows a simple agent which runs
a Finite State Machine Behaviour (FSM).
You need to be running a SPADE platform on the same host
'''
import sys,os
sys.path.append('..'+os.sep+'trunk')
sys.path.append('..')
import spade
import time
class MyAgent(spade.Agent.Agent):
class StateOne(spade.Behaviour.OneShotBehaviour):
def _process(self):
print "This is State One..."
self.myAgent.counter = self.myAgent.counter + 1
if self.myAgent.counter > 2:
self._exitcode = self.myAgent.TRANSITION_TO_TWO
else:
self._exitcode = self.myAgent.TRANSITION_DEFAULT
class StateTwo(spade.Behaviour.OneShotBehaviour):
def _process(self):
print "This is State Two..."
self.myAgent.counter = self.myAgent.counter + 1
if self.myAgent.counter > 5:
self._exitcode = self.myAgent.TRANSITION_TO_THREE
else:
self._exitcode = self.myAgent.TRANSITION_DEFAULT
# MODIFY EXAMPLE #
#####################################
'''
This file shows a simple agent which just modifies its
own information stored in the AMS agent.
You need to be running a SPADE platform on the same host
'''
import sys,os
sys.path.append('..'+os.sep+'trunk')
sys.path.append('..')
import spade
class MyAgent(spade.Agent.Agent):
class MyBehav(spade.Behaviour.OneShotBehaviour):
def onStart(self):
print "Starting behaviour . . ."
def _process(self):
print "I'm going to modify my data"
aad = spade.AMS.AmsAgentDescription()
#aad.setAID(spade.AID.aid("agent@127.0.0.1",["xmpp://agent@127.0.0.1"]))
aad.ownership = "FREE"
result = self.myAgent.modifyAgent(aad)
if result:
print "Modification OK"
print "I'm going to check the modification"
search = self.myAgent.searchAgent(aad)
print search
def onEnd(self):
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)
#####################################
'''
This file shows a simple agent which just searches for
an agent. Then it prints the results to the screen.
You need to be running a SPADE platform on the same host
'''
import os
import sys
sys.path.append('..'+os.sep+'trunk')
sys.path.append('..')
import spade
class MyAgent(spade.Agent.Agent):
class MyBehav(spade.Behaviour.OneShotBehaviour):
def onStart(self):
print "Starting behaviour . . ."
def _process(self):
print "I'm going to search for an agent"
aad = spade.AMS.AmsAgentDescription()
search = self.myAgent.searchAgent(aad)
for a in search:
print a.asRDFXML()
def onEnd(self):
print "Ending behaviour . . ."
def _setup(self):
print "MyAgent starting . . ."
b = self.MyBehav()