diff --git a/main.py b/main.py index 333c372..267b1af 100644 --- a/main.py +++ b/main.py @@ -43,7 +43,7 @@ if __name__ == "__main__": # Maksymilian go = 0 - randGo = 0 + randomPlate = None plate = 0 waitPos = [[1, 2], [1, 5], [1, 8], [5, 4], [5, 8], [8, 2], [8, 5], [8, 8], [12, 3], [12, 7]] @@ -62,9 +62,10 @@ if __name__ == "__main__": if randrange(30) == 17: plate = random.choice(plateArr) if not plate.empty: - randomPlate = randrange(5) + 10 + randomPlate = randrange(4) + 11 plate.changePlate('plate-empty.png', 'test-{}'.format(randomPlate)) + def addGuest(): if randrange(10) == 5 and path == '': newGuests.append(Guest(graphics)) @@ -76,7 +77,6 @@ if __name__ == "__main__": tree.TasksList('order', goal, [waiter.X, waiter.Y]) - tree.print() print(actions) return tree.ReturnQueueList() @@ -84,7 +84,7 @@ if __name__ == "__main__": while True: changePlate() - #queue = addGuest() + # queue = addGuest() for event in pygame.event.get(): # rabbit.check(waiter.matrix, waiter.X, waiter.Y) @@ -156,65 +156,68 @@ if __name__ == "__main__": tree.TasksList('goToBar', goalList, [waiter.X, waiter.Y]) queue = tree.ReturnQueueList() - if plate == 1 and (goalList == [waiter.X-1, waiter.Y] or goalList == [waiter.X+1, waiter.Y]): - if (not [waiter.X, waiter.Y] in waitPos) or go == 0: - if [waiter.X, waiter.Y] in waitPos: - model = 'waiter_' + waiter.direction - for x in range(-1, 2): - waiterX = waiter.X + (x * 0.1) - graphics.clear(waiterX, waiter.Y - 1) - rand = randrange(9) + if plateArr and event.key == pygame.K_m: + randomPlate = random.choice(plateArr) + if (not [waiter.X, waiter.Y] == randomPlate.table) or go == 0: + print(waiter.X, waiter.Y) + print(randomPlate.table) + print(go) + print([waiter.X, waiter.Y] in randomPlate.table) + if [waiter.X, waiter.Y] in waitPos: + model = 'waiter_' + waiter.direction + for x in range(-1, 2): + waiterX = waiter.X + (x * 0.1) + graphics.clear(waiterX, waiter.Y - 1) + print(randomPlate) + # if this plate is exists + goal = (randomPlate.table[0], randomPlate.table[1]) + path = waiter.findPath(goal) + path = waiter.translatePath(path) + print('sec-1') - # if this plate is exists - print(rand) - if plateArr and len(plateArr) > rand and plateArr[rand] in plateArr: - randGo = rand - goal = (plateArr[randGo].table[0], plateArr[randGo].table[1]) - path = waiter.findPath(goal) - path = waiter.translatePath(path) - print('sec-1') - - go = 1 - plate = 0 - - # if this plate is not exists - else: - - randTable = goalList - randIndex = pltPos.index(goalList) - tableCord = tabPos[randIndex] - plateCord = pltPos[randIndex] - print('rand{}'.format(randIndex)) - pictureAI = 'test-{}'.format(randIndex) - plateArr.append(Plate(graphics, plateCord, tableCord, 'plate-full.png', pictureAI)) - tabPos.pop(randIndex) - pltPos.pop(randIndex) - print(plateArr, pltPos) - - goal = (plateArr[len(plateArr) - 1].table[0], plateArr[len(plateArr) - 1].table[1]) - randGo = len(plateArr) - 1 - path = waiter.findPath(goal) - path = waiter.translatePath(path) - print('sec-2') - go = 1 - plate = 0 - else: - if plateArr[randGo].checked: - predict = 'CHECKED' - else: - predict = use_model_to_predict(plateArr[randGo].pictureAI) - - if predict == 1: - predict = 'EMPTY' - plateArr[randGo].checkPlate() + go = 1 + plate = 0 else: - predict = 'FOOD' - print('sec-3') - text_speech('arialnarrow.ttf', 25, predict, (255, 255, 255), (0, 128, 0), - (waiter.X * 50 + 25), (waiter.Y * 50 - 25), False, False, screen=graphics.screen) - pygame.display.flip() - go = 0 - plate = 0 + if randomPlate.checked: + predict = 'CHECKED' + else: + predict = use_model_to_predict(randomPlate.pictureAI) + + if predict == 1: + predict = 'EMPTY' + + randomPlate.clearTable() + plateArr.remove(randomPlate) + + else: + predict = 'FOOD' + print('sec-3') + text_speech('arialnarrow.ttf', 25, predict, (255, 255, 255), (0, 128, 0), + (waiter.X * 50 + 25), (waiter.Y * 50 - 25), False, False, screen=graphics.screen) + pygame.display.flip() + go = 0 + plate = 0 + + if plate == 1 and (goalList == [waiter.X - 1, waiter.Y] or goalList == [waiter.X + 1, waiter.Y]): + randTable = goalList + randIndex = pltPos.index(goalList) + tableCord = tabPos[randIndex] + plateCord = pltPos[randIndex] + print('rand{}'.format(randIndex)) + pictureAI = 'test-{}'.format(randIndex) + plateArr.append(Plate(graphics, plateCord, tableCord, 'plate-full.png', pictureAI)) + tabPos.pop(randIndex) + pltPos.pop(randIndex) + print(plateArr, pltPos) + + goal = (plateArr[len(plateArr) - 1].table[0], plateArr[len(plateArr) - 1].table[1]) + randGo = len(plateArr) - 1 + path = waiter.findPath(goal) + path = waiter.translatePath(path) + print('sec-2') + go = 1 + plate = 0 + # Dominik if queue and path == '' and fromBar == 0: diff --git a/src/plate.py b/src/plate.py index 9d87f59..a09750c 100644 --- a/src/plate.py +++ b/src/plate.py @@ -15,5 +15,5 @@ class Plate: self.pictureAI = newPictureAI self.empty = True - def checkPlate(self): - self.checked = True + def clearTable(self): + self.graphics.clearPlate(self.plate[0], self.plate[1])