diff --git a/agent2.py b/agent2.py index cb92acf..857cb6c 100644 --- a/agent2.py +++ b/agent2.py @@ -69,6 +69,7 @@ class Creature(Agent): damage = attackValue - defenseValue if (damage > 0) and (damage + self.weapon1.damage - opponent.armor.mag_protection > 0): opponent.health = opponent.health - (damage + self.weapon1.damage - opponent.armor.mag_protection) + def defaultAttack(self,opponent): if self.weapon1.type == "Meele": self.meleeAttack(opponent) diff --git a/model.py b/model.py index f4d2903..7c2d078 100644 --- a/model.py +++ b/model.py @@ -9,12 +9,12 @@ import random x = 10 y = 10 step_counter = 0 -boxes_number = 5 -creatures_number = 5 +boxes_number = 10 +creatures_number = 10 class GameMap(Model): - def __init__(self, x, y, boxes_number): + def __init__(self, x, y): self.grid = MultiGrid(x, y, False) self.schedule = RandomActivation(self) # agenci losowo po kolei wykonują swoje akcje # to jest potrzebne przy założeniu, że potwory chodzą? @@ -30,23 +30,24 @@ class GameMap(Model): for i in range(self.boxes_number): box = Box(i, self) - self.schedule.add(box) + #self.schedule.add(box) x = self.random.randrange(self.grid.width) y = self.random.randrange(self.grid.height) - try: + if self.grid.is_cell_empty((x, y)): self.grid.place_agent(box, (x, y)) - except: + self.schedule.add(box) + else: pass for i in range(self.boxes_number, self.boxes_number+self.creatures_number): #taki range, żeby każdy agent miał poprawne unique_id #creature = Creature(i, self) - creature = Creature(i, self, "Goblin", 0, 0, 0, 1, 1, WM2,A2, dice(6)) - self.schedule.add(creature) + creature = Creature(i, self, "Goblin", 1, 1, 1, 1, 1, WM2,A2, dice(6)) x = self.random.randrange(self.grid.width) y = self.random.randrange(self.grid.height) - try: + if self.grid.is_cell_empty((x, y)): self.grid.place_agent(creature, (x, y)) - except: + self.schedule.add(creature) + else: pass diff --git a/server.py b/server.py index dc07617..f8c0e2d 100644 --- a/server.py +++ b/server.py @@ -17,6 +17,6 @@ grid = CanvasGrid(player_representation, 10, 10, 500, 500) server = ModularServer(GameMap, [grid], "Map", - {"x":10, "y":10, "boxes_number":5}) + {"x":10, "y":10}) server.port = 8521 server.launch() \ No newline at end of file