示例#1
0
    }, {
        'title': 'Game of Thrones',
        'author': 'A. M. M. Martin',
        'qty': 10,
        'how much is': 53.80
    }]

    bookStoresInfo = [(AID(name='Cultura'), bookslist_Cultura),
                      (AID(name='Saraiva'), booksList_Saraiva)]

    order = {
        'title': 'The Lord of the Rings',
        'author': 'J. R. R. Tolkien',
        'qty': 5
    }

    #set_ams('localhost', 8000)

    agents = []
    #saraiva = BookstoreAgent(AID(name='[email protected]:2002'), booksList_Saraiva)
    saraiva = BookstoreAgent(AID(name='Saraiva'), booksList_Saraiva)
    saraiva.set_ams()
    agents.append(saraiva)

    #cultura = BookstoreAgent(AID(name='[email protected]:2003'), bookslist_Cultura)
    cultura = BookstoreAgent(AID(name='Cultura'), bookslist_Cultura)
    cultura.set_ams()
    agents.append(cultura)

    start_loop(agents)
示例#2
0
	def __init__(self, aid):
		Agent.__init__(self, aid)
		
	def on_start
on_start(self):
		Agent.on_start
on_start(self)
		display_message(self.aid.name, "Hello World")
		if 'Bob' in self.aid.name:
			message = ACLMessage(ACLMessage.INFORM)
			message.add_receiver(AID('Alice'))
			message.set_content('Hello Alice!')
			self.send(message)
	
	def react(self, message):
		Agent.react(self, message)
		display_message(self.aid.name, message.get_message())

if __name__ == '__main__':
	set_ams('localhost', 8000)
	
	agente = Teste(AID('Alice'))
	agente.set_ams('localhost', 8000)
	agente.start()
	
	agente = Teste(AID('Bob'))
	agente.set_ams('localhost', 8000)
	agente.start()
	
	start_loop()
示例#3
0
        message.set_content(dumps(pedido))
        message.add_receiver('participant_agent_1')
        message.add_receiver('participant_agent_2')
        behaviour = InitiatorProtocol(self, message)
        self.addBehaviour(behaviour)

class ParticipantAgent(Agent):
    
    def __init__(self, aid, power_values):
        Agent.__init__(self, aid)
        behaviour = ParticipantProtocol(self, power_values)
        self.addBehaviour(behaviour)

if __name__ == '__main__':
    
    set_ams('localhost', 8000)
    
    agent_participant_1 = ParticipantAgent(AID('participant_agent_1'), {'value' : 100.0})
    agent_participant_1.set_ams('localhost', 8000)
    agent_participant_1.start()
    
    agent_participant_2 = ParticipantAgent(AID('participant_agent_2'), {'value' : 200.0})
    agent_participant_2.set_ams('localhost', 8000)
    agent_participant_2.start()
    
    agent_initiator = InitiatorAgent(AID('initiator_agent'))
    agent_initiator.set_ams('localhost', 8000)
    agent_initiator.start()
    
    start_loop()
class AgenteConsumidor(Agent):
    def __init__(self, aid, bookStores, pedido):
        Agent.__init__(self, aid)

        self.bookStores = bookStores
        self.pedido = pedido

        cfp_message = ACLMessage(ACLMessage.CFP)
        cfp_message.set_protocol(ACLMessage.FIPA_CONTRACT_NET_PROTOCOL)
        for i in self.bookStores:
            cfp_message.add_receiver(i)
        cfp_message.set_content(dumps(self.pedido))

        comportamento = ComportamentoAgenteConsumidor(self, cfp_message)
        self.addBehaviour(comportamento)


if __name__ == "__main__":

    agents = []
    pedido = {"title": "The Lord of the Rings", "author": "J. R. R. Tolkien", "qtd": 5}

    # consumidor = AgenteConsumidor(AID('[email protected]:2004'), ['Saraiva', 'Cultura', 'Nobel'], pedido)
    consumidor = AgenteConsumidor(AID("Lucas"), ["Saraiva", "Cultura", "Nobel"], pedido)

    consumidor.set_ams()
    agents.append(consumidor)

    start_loop(agents)
示例#5
0
            message.set_content('Ola Agente!')
            self.send(message)
            display_message(self.aid.name, 'Enviando mensagem...')
    
    def react(self, message):
        Agent.react(self, message)
        display_message(self.aid.name, 'Uma mensagem recebida')

        if 'agente_teste_participante' in self.aid.name:
            resposta = message.create_reply()
            resposta.set_content('Ola tambem agente!')
            self.send(resposta)

if __name__ == '__main__':
    
    set_ams('localhost', 8000)

    agente_teste_iniciante = Teste(AID('agente_teste_iniciante'))

    agente_teste_participante = Teste(AID('agente_teste_participante'))

    agentes = list()

    print id(agente_teste_iniciante)
    print id(agente_teste_participante)

    agentes.append(agente_teste_participante)
    agentes.append(agente_teste_iniciante)
    
    start_loop(agentes)
示例#6
0
            self.send(message)
            display_message(self.aid.name, 'Enviando mensagem...')

    def react(self, message):
        Agent.react(self, message)
        display_message(self.aid.name, 'Uma mensagem recebida')

        if 'agente_teste_participante' in self.aid.name:
            resposta = message.create_reply()
            resposta.set_content('Ola tambem agente!')
            self.send(resposta)


if __name__ == '__main__':

    set_ams('localhost', 8000)

    agente_teste_iniciante = Teste(AID('agente_teste_iniciante'))

    agente_teste_participante = Teste(AID('agente_teste_participante'))

    agentes = list()

    print id(agente_teste_iniciante)
    print id(agente_teste_participante)

    agentes.append(agente_teste_participante)
    agentes.append(agente_teste_iniciante)

    start_loop(agentes)