from mesa import Model from hero import Player from othercharacters import Creature, Box, Wall, dice from armory import WM1, A1, WR1, S1, WM2, A2 from mesa.time import RandomActivation from mesa.space import MultiGrid # from mesa.datacollection import DataCollector import random x = 10 y = 10 step_counter = 0 boxes_number = 4 creatures_number = 5 class GameMap(Model): def __init__(self, x, y): self.listOfChests = [] 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ą? self.boxes_number = boxes_number self.creatures_number = creatures_number self.running = True # player = Player(1000, self) player = Player(1000, self, "Janusz", 3, 3, 3, 20, 20, WM1, A1, 0, WR1, S1, self.listOfChests) self.schedule.add(player) x = self.random.randrange(self.grid.width) y = self.random.randrange(self.grid.height) self.grid.place_agent(player, (x, y)) for i in range(self.boxes_number): box = Box(i, self) # self.schedule.add(box) x = self.random.randrange(self.grid.width) y = self.random.randrange(self.grid.height) if self.grid.is_cell_empty((x, y)): self.grid.place_agent(box, (x, y)) self.schedule.add(box) self.listOfChests.append([i, [x, y]]) #fetching chest position - [index, [OX, OY]] 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", 1, 1, 1, 1, 1, WM2, A2, dice(6)) x = self.random.randrange(self.grid.width) y = self.random.randrange(self.grid.height) if self.grid.is_cell_empty((x, y)): self.grid.place_agent(creature, (x, y)) self.schedule.add(creature) else: pass # self.datacollector=DataCollector #informacje o stanie planszy, pozycja agenta def get_listOfChests(self): return self.listOfChests def step(self): self.schedule.step() # self.datacollector.collect(self) #na razie niepotrzebne