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
(...)
super(YourSimulation, self).__init__(**kargs)
, during the parent init call Agent class and informe who is the simulation.
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 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):
(...)
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)
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()
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.
horse ./examples/horse/
each horse goes straight until one touch the finish line
robot ./examples/robot/
robots (black rectangles) research resources (blue rectangles).
morse ./examples/morse/
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 __.