Add good checking plates

This commit is contained in:
s450026 2020-06-09 19:26:53 +02:00
parent 575a2def45
commit 5be76f9a4b
2 changed files with 66 additions and 63 deletions

125
main.py
View File

@ -43,7 +43,7 @@ if __name__ == "__main__":
# Maksymilian # Maksymilian
go = 0 go = 0
randGo = 0 randomPlate = None
plate = 0 plate = 0
waitPos = [[1, 2], [1, 5], [1, 8], [5, 4], [5, 8], waitPos = [[1, 2], [1, 5], [1, 8], [5, 4], [5, 8],
[8, 2], [8, 5], [8, 8], [12, 3], [12, 7]] [8, 2], [8, 5], [8, 8], [12, 3], [12, 7]]
@ -62,9 +62,10 @@ if __name__ == "__main__":
if randrange(30) == 17: if randrange(30) == 17:
plate = random.choice(plateArr) plate = random.choice(plateArr)
if not plate.empty: if not plate.empty:
randomPlate = randrange(5) + 10 randomPlate = randrange(4) + 11
plate.changePlate('plate-empty.png', 'test-{}'.format(randomPlate)) plate.changePlate('plate-empty.png', 'test-{}'.format(randomPlate))
def addGuest(): def addGuest():
if randrange(10) == 5 and path == '': if randrange(10) == 5 and path == '':
newGuests.append(Guest(graphics)) newGuests.append(Guest(graphics))
@ -76,7 +77,6 @@ if __name__ == "__main__":
tree.TasksList('order', goal, [waiter.X, waiter.Y]) tree.TasksList('order', goal, [waiter.X, waiter.Y])
tree.print() tree.print()
print(actions) print(actions)
return tree.ReturnQueueList() return tree.ReturnQueueList()
@ -84,7 +84,7 @@ if __name__ == "__main__":
while True: while True:
changePlate() changePlate()
#queue = addGuest() # queue = addGuest()
for event in pygame.event.get(): for event in pygame.event.get():
# rabbit.check(waiter.matrix, waiter.X, waiter.Y) # rabbit.check(waiter.matrix, waiter.X, waiter.Y)
@ -156,65 +156,68 @@ if __name__ == "__main__":
tree.TasksList('goToBar', goalList, [waiter.X, waiter.Y]) tree.TasksList('goToBar', goalList, [waiter.X, waiter.Y])
queue = tree.ReturnQueueList() queue = tree.ReturnQueueList()
if plate == 1 and (goalList == [waiter.X-1, waiter.Y] or goalList == [waiter.X+1, waiter.Y]): if plateArr and event.key == pygame.K_m:
if (not [waiter.X, waiter.Y] in waitPos) or go == 0: randomPlate = random.choice(plateArr)
if [waiter.X, waiter.Y] in waitPos: if (not [waiter.X, waiter.Y] == randomPlate.table) or go == 0:
model = 'waiter_' + waiter.direction print(waiter.X, waiter.Y)
for x in range(-1, 2): print(randomPlate.table)
waiterX = waiter.X + (x * 0.1) print(go)
graphics.clear(waiterX, waiter.Y - 1) print([waiter.X, waiter.Y] in randomPlate.table)
rand = randrange(9) 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 go = 1
print(rand) plate = 0
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()
else: else:
predict = 'FOOD' if randomPlate.checked:
print('sec-3') predict = 'CHECKED'
text_speech('arialnarrow.ttf', 25, predict, (255, 255, 255), (0, 128, 0), else:
(waiter.X * 50 + 25), (waiter.Y * 50 - 25), False, False, screen=graphics.screen) predict = use_model_to_predict(randomPlate.pictureAI)
pygame.display.flip()
go = 0 if predict == 1:
plate = 0 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 # Dominik
if queue and path == '' and fromBar == 0: if queue and path == '' and fromBar == 0:

View File

@ -15,5 +15,5 @@ class Plate:
self.pictureAI = newPictureAI self.pictureAI = newPictureAI
self.empty = True self.empty = True
def checkPlate(self): def clearTable(self):
self.checked = True self.graphics.clearPlate(self.plate[0], self.plate[1])