agent.py 836 B
import random
import sys
from iotAmak.agent import Agent
class Ant(Agent):
def __init__(self, identifier: int, broker_ip: str):
self.x = 250
self.y = 250
super().__init__(identifier, broker_ip)
def on_initialization(self) -> None:
pass
def on_cycle_begin(self) -> None:
pass
def on_perceive(self) -> None:
pass
def on_decide(self) -> None:
pass
def on_act(self) -> None:
self.x += random.randint(-5, +5)
self.y += random.randint(-5, +5)
def on_cycle_end(self) -> None:
pass
def send_metric(self):
metric = super(Ant, self).send_metric()
metric["x"] = self.x
metric["y"] = self.y
return metric
if __name__ == '__main__':
a = Ant(int(sys.argv[1]), str(sys.argv[2]))
a.run()