diff --git a/app.py b/app.py index bdae6b1..523358f 100644 --- a/app.py +++ b/app.py @@ -50,6 +50,10 @@ def initBoard(): cells[6][2].interactableItem = Table(cells[6][2], "Table") cells[4][2].interactableItem = Table(cells[4][2], "Table") + for cell in cells: + for cel in cell: + cel.waga = Agent.get_cost((cel.X, cel.Y), cells) + cells[9][9].waga = 2 cells[9][8].waga = 10 cells[8][8].waga = 10 diff --git a/classes/agent.py b/classes/agent.py index ec9ed83..1c40b61 100644 --- a/classes/agent.py +++ b/classes/agent.py @@ -281,13 +281,13 @@ class Agent: else: print("Agent cannot move to this direction") - def get_cost(self, cell): + def get_cost(cell, cells): x, y = cell[0], cell[1] - if x == 0 or x == len(self.cells) - 1 or y == 0 or y == len(self.cells[0]) - 1: + if x == 0 or x == len(cells) - 1 or y == 0 or y == len(cells[0]) - 1: return 15 # Koszt dla pól na krawędziach - elif x == 1 or x == len(self.cells) - 2 or y == 1 or y == len(self.cells[0]) - 2: + elif x == 1 or x == len(cells) - 2 or y == 1 or y == len(cells[0]) - 2: return 10 # Koszt dla pól drugiego rzędu i przedostatniego oraz drugiej kolumny i przedostatniej - elif x == 2 or x == len(self.cells) - 3 or y == 2 or y == len(self.cells[0]) - 3: + elif x == 2 or x == len(cells) - 3 or y == 2 or y == len(cells[0]) - 3: return 5 # Koszt dla pól trzeciego rzędu i trzeciego od końca oraz trzeciej kolumny i trzeciej od końca else: return 1