Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exchange of messages between agents with sessions #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

YerayMM
Copy link

@YerayMM YerayMM commented Jul 2, 2019

In order to enable the exchange of messages between agents while executing a code like the following:

from pade.acl.aid import AID
from pade.misc.common import PadeSession
from agents.prosumer_agent import AgentProsumer
from agents.consumer_agent import AgentConsumer

def config_agents():
    agents = list()

    port_prosumer = 8500
    agent_prosumer_name = 'agent_prosumer_{}@localhost:{}'.format(port_prosumer, port_prosumer)
    agent_prosumer = AgentProsumer(AID(name=agent_prosumer_name))
    agents.append(agent_prosumer)

    port_consumer = 8501
    agent_consumer_name = 'agent_consumer_{}@localhost:{}'.format(port_consumer, port_consumer)
    agent_consumer = AgentConsumer(AID(name=agent_consumer_name))
    agents.append(agent_consumer)

    # Declaration of the PadeSession object
    pade_session = PadeSession()
    # Addition of the list of agents
    pade_session.add_all_agents(agents)
    # Registration of users on the platform
    pade_session.register_user(username='yeraymm', email='yeraymm@usal.es', password='12345')

    return pade_session


if __name__ == '__main__':

    s = config_agents()
    # initialization of the execution loop of the agents
    s.start_loop()

I have made changes to:
- core/new_ams.py: in order to allow the use of initialized sessions in the AMS constructor
- misc/common.py: to fix a bug in the in the loop that starts agents which call AgentProcess, a non-defined function.
- core/new_ams.py: to update the table of addresses of each agent in the platform without waiting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant