From 8ec5e96e8cd6caba84277c279cc65a6860638f22 Mon Sep 17 00:00:00 2001 From: shaaqu Date: Mon, 18 May 2020 17:33:48 +0200 Subject: [PATCH] create addShelf method in Field class --- .idea/workspace.xml | 19 +++++++++++++++---- field.py | 8 +++++++- shelf.py | 5 ++--- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index fcf7da5..5c1c2d0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,9 @@ - - - + + @@ -143,6 +150,10 @@ + + + diff --git a/field.py b/field.py index 033612c..c425d69 100644 --- a/field.py +++ b/field.py @@ -1,4 +1,5 @@ import pygame +from shelf import Shelf class Field: @@ -14,6 +15,7 @@ class Field: self.is_occupied_by_agent = is_occupied_by_agent self.cost_of_travel = cost_of_travel self.neighbors = [] + self.shelves = [] # Te parametry są potrzebne do algorytmu A* self.g = 0 @@ -41,4 +43,8 @@ class Field: if self.y > 0 and board[self.y - 1][self.x].is_shelf == False: self.neighbors.append(board[self.y - 1][self.x]) if self.y < 9 and board[self.y + 1][self.x].is_shelf == False: - self.neighbors.append(board[self.y + 1][self.x]) \ No newline at end of file + self.neighbors.append(board[self.y + 1][self.x]) + + def addShelf(self): + shelf = Shelf(len(self.shelves)+1) + self.shelves.append(shelf) \ No newline at end of file diff --git a/shelf.py b/shelf.py index eb9e8f7..3e318d7 100644 --- a/shelf.py +++ b/shelf.py @@ -1,12 +1,11 @@ import pygame + class Shelf: - def __init__(self, id, field): + def __init__(self, id): self.id = id - self.field = field self.products = [] def addProduct(self, sweet): self.products.append(sweet) -