Skip to content

PouceHeure/py_light_mas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py_light_mas

tag:status:status:development

tag:language:python3

architecture

relation

relation

sequence

sequence

use lib

create simulation

create a new child class of Simulation

class YourSimulation(Simulation):
    def __init__(self, ..., **kargs):
        super(YourSimulation, self).__init__(**kargs)
        # create your env and agents here 
        (...)

⚠️ all agents need to be declared after this call super(YourSimulation, self).__init__(**kargs), during the parent init call Agent class and informe who is the simulation.

create environnment

create a new child class of Environnemnt

class YourEnvironnement(Environnemnt):
    
    def __init__(self,...,**kargs):
        super(YourEnvironnement,self).__init__(**kargs)

    def on_event_new_tick(self):
        (...)

    def on_event_show(self):
        (...)

For the moment, Environnement doesn't have a constructor, so use init with **kwargs is useless, but if Environnemnt evolves and need parameters your code still working.

create agent

create a new child class of Agent

class YourAgent(Agent): 

    def __init__(self,...,**kargs):
        super(YourAgent,self).__init__(**kargs)

    def on_event_new_message(self,message): 
        (...)

    def on_event_new_signal(self,message): 
        (...)

    def on_event_new_tick(self,env):
        (...)

create a network

you can create a network where do you want

network = Network("localhost")

if you want to connect an agent to your network

agent = YourAgent("agent1")
agent.connect(network)

run simulation

sim = YourSimulation(...)
# if you want to manage by yourself the loop run 
while(True): 
    (...)
    sim.run() 
    (...)
# if you want to call loop run already implemented 
sim.run_loop()

documentation

The documentation is generated by pdoc3, you can install it by pip3, like this:

$ pip3 install pdoc3

run script gen_doc.sh

$ ./gen_doc.sh

once the script executed, open doc/index.html with your broswer.

examples

⚠️ some examples use pygame=1.9.6

each horse goes straight until one touch the finish line

example-horse

robots (black rectangles) research resources (blue rectangles).

example-robot

2 agents are connected on 2 differents networks, one sends morse message and the second replies with: 'ok + the same content'

[name: agent_A_01 address: team_A/192.168.0.0 network: ://team_A aid: 0 type: SenderAgent] success connection to: team_A
[name: agent_B_01 address: team_B/192.168.0.0 network: ://team_B aid: 1 type: ReplierAgent] success connection to: team_B
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: __...._.__._..__..
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok __...._.__._..__..
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: _..__...
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok _..__...
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: ._.___.___...___.
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok ._.___.___...___.
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: .____._.______...
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok .____._.______...
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: ....___.
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok ....___.
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: ___.____.___
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok ___.____.___
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: .._.__...
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok .._.__...
from: team_A/192.168.0.0 to: team_B/192.168.0.0 content: __.
from: team_B/192.168.0.0 to: team_A/192.168.0.0 content: ok __.

About

Simple multi agents system python library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published