This commit is contained in:
s450026 2020-06-09 16:00:26 +02:00
parent a18927bfb4
commit 74af28c7c2

29
main.py
View File

@ -64,9 +64,31 @@ if __name__ == "__main__":
randomPlate = randrange(5) + 10 randomPlate = randrange(5) + 10
plate.changePlate('plate-empty.png', 'test-{}'.format(randomPlate)) plate.changePlate('plate-empty.png', 'test-{}'.format(randomPlate))
def addGuest():
if randrange(15) == 8:
newGuests.append(Guest(graphics))
guest = newGuests[0]
goal = [0, 0]
if guest.cord[0] == 2 or guest.cord[1] == 9:
goal[0] = guest.cord[0] - 1
goal[1] = guest.cord[1]
else:
goal[0] = guest.cord[0] + 1
goal[1] = guest.cord[1]
tree.TasksList('order', goal, [waiter.X, waiter.Y])
tree.print()
check = 1
print(actions)
return tree.ReturnQueueList()
while True: while True:
changePlate() changePlate()
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)
@ -81,6 +103,8 @@ if __name__ == "__main__":
sys.exit() sys.exit()
break break
if event.key == pygame.K_d:
print(queue)
if event.key == pygame.K_s: if event.key == pygame.K_s:
waitPosition = [waiter.X, waiter.Y] waitPosition = [waiter.X, waiter.Y]
tree.TasksList('check', [2, 3], waitPosition) tree.TasksList('check', [2, 3], waitPosition)
@ -185,7 +209,8 @@ if __name__ == "__main__":
path = waiter.translatePath(path) path = waiter.translatePath(path)
# Dominik # Dominik
if path == '' and fromBar == 0 and check == 1: if queue and path == '' and fromBar == 0:
print('dsads{}'.format(queue))
task = queue.pop(0) task = queue.pop(0)
tree.RemoveTask() tree.RemoveTask()
node = (task[2][0], task[2][1]) node = (task[2][0], task[2][1])
@ -208,7 +233,7 @@ if __name__ == "__main__":
path = path[1:] path = path[1:]
waiter.travel(nextStep, graphics) waiter.travel(nextStep, graphics)
if len(queue) != 0 and check == 0 and path == '' and fromBar == 0: if queue and len(queue) != 0 and check == 0 and path == '' and fromBar == 0:
check = 1 check = 1
# AStar # AStar