Hello World

PADE was implemented with one main objective: simplicity

After you have been installed PADE in your machine, it’s easy start to use PADE

In a folder you will need to create a file named agent_example_1.py with your favorite text editor, then copy and paste the following source code inside the file. Or you can download the file from PADE GitHub repository in examples folder (PADE repository <https://github.com/grei-ufc/pade>). The file agent_example_1.py has the following code:

# Hello world in PADE!
#
# Criado por Lucas S Melo em 21 de julho de 2015 - Fortaleza, Ceará - Brasil

from pade.misc.utility import display_message, start_loop
from pade.core.agent import Agent
from pade.acl.aid import AID
from sys import argv

class AgenteHelloWorld(Agent):
    def __init__(self, aid):
        super(AgenteHelloWorld, self).__init__(aid=aid)
        display_message(self.aid.localname, 'Hello World!')


if __name__ == '__main__':

    agents_per_process = 3
    c = 0
    agents = list()
    for i in range(agents_per_process):
        port = int(argv[1]) + c
        agent_name = 'agent_hello_{}@localhost:{}'.format(port, port)
        agente_hello = AgenteHelloWorld(AID(name=agent_name))
        agents.append(agente_hello)
        c += 1000

    start_loop(agents)

In the terminal command line, type:

$ pade start_runtime --port 20000 agent_example_1.py

Nice! If everything is ok, you must have seen the PADE splash screen, like this:

../_images/pade_splash_screen.png

This already is an agent, but it does not have many utilities, it just starts, prints hello in the screen and dies. :(

So, how can we build agents that have temporal or cyclic behaviours?