Оновити 'main.py'

This commit is contained in:
Serhii Hromov 2020-05-11 13:56:12 +00:00
parent 1ca8c10bf1
commit b5aa20748c

752
main.py
View File

@ -1,358 +1,394 @@
import pygame import pygame
from math import sqrt from math import sqrt
from math import floor from math import floor
import random import random
from queue import PriorityQueue from queue import PriorityQueue
pygame.init() import pygad
from concepts import *
#ai settings from graphviz import *
S_IDLE = ("kitchen", "middle", "inplace") import numpy as np
S_FIRST = ("order", "food")
pygame.init()
IDLE = random.choice(S_IDLE)
FIRST = random.choice(S_FIRST) #ai settings
S_IDLE = ("kitchen", "middle", "inplace")
HEIGHT = 10 S_FIRST = ("order", "food")
WIDTH = 10
IDLE = random.choice(S_IDLE)
KITCHEN = (1, 1) FIRST = random.choice(S_FIRST)
MIDDLE = (floor(WIDTH/2), floor(HEIGHT/2))
HEIGHT = 10
WIDTH = 10
display = pygame.display.set_mode((WIDTH*32+200, HEIGHT*32))
KITCHEN = (1, 1)
#eating time MIDDLE = (floor(WIDTH/2), floor(HEIGHT/2))
EAT_TIME = 15
class Tile: display = pygame.display.set_mode((WIDTH*32+200, HEIGHT*32))
def __init__(self, x, y, canwalk, table, kitchen):
self.x = x #eating time
self.y = y EAT_TIME = 15
self.canwalk = canwalk
self.table = table #### Menu
self.kitchen = kitchen menu = Context.fromstring(''' |meat|salad|meal|drink|cold|hot |
self.client = False Pork | X | | X | | | X |
self.clientState = False Espresso | | | | X | | X |
self.visited = False Green Tea | | | | X | X | |
self.path = False Greek Salad| | X | X | | X | |
self.parent = (0, 0) Pizza | | | X | | | X |''')
class Restaurant:
def __init__(self, tables, clients):
self.h = HEIGHT #genetic algos
self.w = WIDTH gen_num = 20 #generations
self.tiles = [] gen_sol = 6 #solutions
self.tables = [] gen_par_mating = 2 #how many solutions we select
self.clients = clients
self.kitchen = [] mut_per_gen = 10
self.left = clients mut_num_gen = None
for ih in range(HEIGHT):
new = [] crossover = "two_points"
for iw in range(WIDTH): muta_type = "scramble"
if ih == 0 or ih == HEIGHT-1 or iw == 0 or iw == WIDTH-1: par_keep = 1 #keep only one parent
new.append(Tile(ih, iw, False, False, False))
else: init_range_l = -2 #low
new.append(Tile(ih, iw, True, False, False)) init_range_h = -5 #high
self.tiles.append(new)
#random walls func_input = ['meal']
for i in range(3): func_output = []
w = random.randint(1,2)
h = random.randint(4,HEIGHT-5) for e in menu.extension(['meal',]):
for j in range(random.randint(1,3)): func_output.append(e)
ad = self.adjacent(w, h)
t = random.choice(ad) ####
w = t.x class Tile:
h = t.y def __init__(self, x, y, canwalk, table, kitchen):
self.tiles[w][h].canwalk = False self.x = x
#random tables self.y = y
i = 0 self.canwalk = canwalk
while i < tables: self.table = table
w = random.randint(2,WIDTH-3) self.kitchen = kitchen
h = random.randint(2,HEIGHT-3) self.client = False
if not self.tiles[h][w].table and self.tiles[h][w].canwalk: self.clientState = False
self.tiles[h][w].table = True self.visited = False
i = i + 1 self.path = False
self.tables.append((w, h)) self.parent = (0, 0)
class Restaurant:
self.tiles[1][1].kitchen = True def __init__(self, tables, clients):
def putClient(self): self.h = HEIGHT
for t in self.tables: self.w = WIDTH
if not self.tiles[t[1]][t[0]].clientState: self.tiles = []
self.tiles[t[1]][t[0]].client = 30 self.tables = []
self.tiles[t[1]][t[0]].clientState = "decide" self.clients = clients
self.clients = self.clients - 1 self.kitchen = []
break self.left = clients
for ih in range(HEIGHT):
def flush(self): new = []
for ih in range(HEIGHT): for iw in range(WIDTH):
for iw in range(WIDTH): if ih == 0 or ih == HEIGHT-1 or iw == 0 or iw == WIDTH-1:
self.tiles[ih][iw].visited = False new.append(Tile(ih, iw, False, False, False))
self.tiles[ih][iw].parent = (0,0) else:
new.append(Tile(ih, iw, True, False, False))
def adjacent(self, x, y): self.tiles.append(new)
tiles = [] #random walls
if x == 0 or y == 0 or x == WIDTH or y == HEIGHT: for i in range(3):
tiles.append(self.tiles[y][x]) w = random.randint(1,2)
return tiles h = random.randint(4,HEIGHT-5)
tiles.append(self.tiles[y][x-1]) for j in range(random.randint(1,3)):
tiles.append(self.tiles[y-1][x]) ad = self.adjacent(w, h)
tiles.append(self.tiles[y+1][x]) t = random.choice(ad)
tiles.append(self.tiles[y][x+1]) w = t.x
return tiles h = t.y
self.tiles[w][h].canwalk = False
#random tables
def heuristic(a, b): i = 0
(x1, y1) = a while i < tables:
(x2, y2) = b w = random.randint(2,WIDTH-3)
return abs(x1 - x2) + abs(y1 - y2) h = random.randint(2,HEIGHT-3)
if not self.tiles[h][w].table and self.tiles[h][w].canwalk:
class Agent: self.tiles[h][w].table = True
def __init__(self, x, y): i = i + 1
self.x = x self.tables.append((w, h))
self.y = y
self.path = [] self.tiles[1][1].kitchen = True
self.idle = True def putClient(self):
self.orders = [] for t in self.tables:
self.food = False if not self.tiles[t[1]][t[0]].clientState:
def walk(self): self.tiles[t[1]][t[0]].client = 30
t = self.path.pop(0) self.tiles[t[1]][t[0]].clientState = "decide"
self.x = t[0] self.clients = self.clients - 1
self.y = t[1] break
if not self.path:
self.idle = True def flush(self):
def BFS(self, goal): for ih in range(HEIGHT):
restaurant.flush() for iw in range(WIDTH):
queue = [(self.x, self.y)] self.tiles[ih][iw].visited = False
while len(queue) > 0: self.tiles[ih][iw].parent = (0,0)
n = queue.pop(0)
restaurant.tiles[n[1]][n[0]].visited = True def adjacent(self, x, y):
if n == goal: tiles = []
while not n == (self.x, self.y): if x == 0 or y == 0 or x == WIDTH or y == HEIGHT:
self.path.insert(0, n) tiles.append(self.tiles[y][x])
n = restaurant.tiles[n[1]][n[0]].parent return tiles
return tiles.append(self.tiles[y][x-1])
adj = restaurant.adjacent(n[1], n[0]) tiles.append(self.tiles[y-1][x])
for item in adj: tiles.append(self.tiles[y+1][x])
x = item.x tiles.append(self.tiles[y][x+1])
y = item.y return tiles
if restaurant.tiles[y][x].canwalk and not restaurant.tiles[y][x].visited:
queue.append((x,y))
restaurant.tiles[y][x].parent = n def heuristic(a, b):
def wait(self): (x1, y1) = a
self.idle = True (x2, y2) = b
def getTask(self): return abs(x1 - x2) + abs(y1 - y2)
if waiter.orders:
self.BFS(KITCHEN) class Agent:
self.idle = False def __init__(self, x, y):
return True self.x = x
if FIRST == "order": self.y = y
for table in restaurant.tables: self.path = []
if restaurant.tiles[table[1]][table[0]].clientState == "order": self.idle = True
self.BFS((table[0], table[1])) self.orders = []
self.idle = False self.food = False
return True def walk(self):
if not waiter.food: t = self.path.pop(0)
for t in restaurant.kitchen: self.x = t[0]
if not t[2]: self.y = t[1]
waiter.BFS(KITCHEN) if not self.path:
self.idle = False self.idle = True
return True def BFS(self, goal):
elif FIRST == "food": restaurant.flush()
if not waiter.food: queue = [(self.x, self.y)]
for t in restaurant.kitchen: while len(queue) > 0:
if not t[2]: n = queue.pop(0)
waiter.BFS(KITCHEN) restaurant.tiles[n[1]][n[0]].visited = True
self.idle = False if n == goal:
return True while not n == (self.x, self.y):
for table in restaurant.tables: self.path.insert(0, n)
if restaurant.tiles[table[1]][table[0]].clientState == "order": n = restaurant.tiles[n[1]][n[0]].parent
self.BFS((table[0], table[1])) return
self.idle = False adj = restaurant.adjacent(n[1], n[0])
return True for item in adj:
return False x = item.x
y = item.y
if restaurant.tiles[y][x].canwalk and not restaurant.tiles[y][x].visited:
def drawScreen(): queue.append((x,y))
pygame.draw.rect(display,(0,0,0), (0, 0, HEIGHT*32, WIDTH*32)) restaurant.tiles[y][x].parent = n
for ih in range(HEIGHT): def wait(self):
for iw in range(WIDTH): self.idle = True
tile = restaurant.tiles[ih][iw] def getTask(self):
if tile.canwalk: if waiter.orders:
pygame.draw.rect(display, (128,128,128), (iw * 32+1, ih * 32+1, 32-1, 32-1)) self.BFS(KITCHEN)
if tile.table: self.idle = False
if tile.clientState: return True
if tile.clientState == "decide": if FIRST == "order":
pygame.draw.rect(display, (0,128,0), (iw * 32+1, ih * 32+1, 32-1, 32-1)) for table in restaurant.tables:
elif tile.clientState == "order": if restaurant.tiles[table[1]][table[0]].clientState == "order":
pygame.draw.rect(display, (0,255,0), (iw * 32+1, ih * 32+1, 32-1, 32-1)) self.BFS((table[0], table[1]))
elif tile.clientState == "wait": self.idle = False
pygame.draw.rect(display, (255,128,0), (iw * 32+1, ih * 32+1, 32-1, 32-1)) return True
elif tile.clientState == "eat": if not waiter.food:
pygame.draw.rect(display, (128,64,0), (iw * 32+1, ih * 32+1, 32-1, 32-1)) for t in restaurant.kitchen:
else: if not t[2]:
pygame.draw.rect(display, (64,64,64), (iw * 32+1, ih * 32+1, 32-1, 32-1)) waiter.BFS(KITCHEN)
if tile.kitchen: self.idle = False
pygame.draw.rect(display, (255,0,255), (iw * 32 + 1, ih * 32+1, 32-1, 32-1)) return True
#if tile.visited: elif FIRST == "food":
# pygame.draw.rect(display, (64,0,64), (iw * 32 + 1, ih * 32+1, 14, 14)) if not waiter.food:
else: for t in restaurant.kitchen:
pygame.draw.rect(display, (128,0,128), (iw * 32+1, ih * 32+1, 32-1, 32-1)) if not t[2]:
pygame.draw.circle(display, (255,255,255), (waiter.x*32+16, waiter.y*32+16), 16) waiter.BFS(KITCHEN)
self.idle = False
textsurface = font.render(str(restaurant.clients), False, (255,255,255)) return True
display.blit(textsurface, (WIDTH*32 + 80, 300)) for table in restaurant.tables:
if restaurant.tiles[table[1]][table[0]].clientState == "order":
pygame.draw.rect(display,(0,0,0), (WIDTH*32+80, 332, HEIGHT*32, WIDTH*32)) self.BFS((table[0], table[1]))
textsurface = font.render(str(ticks), False, (255,255,255)) self.idle = False
display.blit(textsurface, (WIDTH*32 + 80, 332)) return True
return False
restaurant = Restaurant(3, 5)
waiter = Agent(2,2)
clientTime = 10 def drawScreen():
totaltime = 0 pygame.draw.rect(display,(0,0,0), (0, 0, HEIGHT*32, WIDTH*32))
for ih in range(HEIGHT):
for iw in range(WIDTH):
clock = pygame.time.Clock() tile = restaurant.tiles[ih][iw]
ticks = 0 if tile.canwalk:
#draw info pygame.draw.rect(display, (128,128,128), (iw * 32+1, ih * 32+1, 32-1, 32-1))
help = True if tile.table:
if help: if tile.clientState:
font = pygame.font.SysFont('Arial', 18) if tile.clientState == "decide":
textsurface = font.render("kelner", False, (255,255,255)) pygame.draw.rect(display, (0,128,0), (iw * 32+1, ih * 32+1, 32-1, 32-1))
pygame.draw.circle(display, (255,255,255), (WIDTH*32 + 26, 16), 16) elif tile.clientState == "order":
display.blit(textsurface, (WIDTH*32 + 50, 0)) pygame.draw.rect(display, (0,255,0), (iw * 32+1, ih * 32+1, 32-1, 32-1))
textsurface = font.render("sciana", False, (255,255,255)) elif tile.clientState == "wait":
pygame.draw.rect(display, (128,0,128), (WIDTH*32 + 10, 32, 32-1, 32-1)) pygame.draw.rect(display, (255,128,0), (iw * 32+1, ih * 32+1, 32-1, 32-1))
display.blit(textsurface, (WIDTH*32 + 50, 32)) elif tile.clientState == "eat":
textsurface = font.render("stolik - pusty", False, (255,255,255)) pygame.draw.rect(display, (128,64,0), (iw * 32+1, ih * 32+1, 32-1, 32-1))
pygame.draw.rect(display, (64,64,64), (WIDTH*32 + 10, 64, 32-1, 32-1)) else:
display.blit(textsurface, (WIDTH*32 + 50, 64)) pygame.draw.rect(display, (64,64,64), (iw * 32+1, ih * 32+1, 32-1, 32-1))
textsurface = font.render("stolik - decyduje", False, (255,255,255)) if tile.kitchen:
pygame.draw.rect(display, (0,128,0), (WIDTH*32 + 10, 96, 32-1, 32-1)) pygame.draw.rect(display, (255,0,255), (iw * 32 + 1, ih * 32+1, 32-1, 32-1))
display.blit(textsurface, (WIDTH*32 + 50, 96)) #if tile.visited:
textsurface = font.render("stolik - zamawia", False, (255,255,255)) # pygame.draw.rect(display, (64,0,64), (iw * 32 + 1, ih * 32+1, 14, 14))
pygame.draw.rect(display, (0,255,0), (WIDTH*32 + 10, 128, 32-1, 32-1)) else:
display.blit(textsurface, (WIDTH*32 + 50, 128)) pygame.draw.rect(display, (128,0,128), (iw * 32+1, ih * 32+1, 32-1, 32-1))
textsurface = font.render("stolik - czeka", False, (255,255,255)) pygame.draw.circle(display, (255,255,255), (waiter.x*32+16, waiter.y*32+16), 16)
pygame.draw.rect(display, (255,128,0), (WIDTH*32 + 10, 160, 32-1, 32-1))
display.blit(textsurface, (WIDTH*32 + 50, 160)) textsurface = font.render(str(restaurant.clients), False, (255,255,255))
textsurface = font.render("stolik - je", False, (255,255,255)) display.blit(textsurface, (WIDTH*32 + 80, 300))
pygame.draw.rect(display, (128,64,0), (WIDTH*32 + 10, 192, 32-1, 32-1))
display.blit(textsurface, (WIDTH*32 + 50, 192)) pygame.draw.rect(display,(0,0,0), (WIDTH*32+80, 332, HEIGHT*32, WIDTH*32))
textsurface = font.render("kuchnia", False, (255,255,255)) textsurface = font.render(str(ticks), False, (255,255,255))
pygame.draw.rect(display, (255,0,255), (WIDTH*32 + 10, 224, 32-1, 32-1)) display.blit(textsurface, (WIDTH*32 + 80, 332))
display.blit(textsurface, (WIDTH*32 + 50, 224))
restaurant = Restaurant(3, 5)
textsurface = font.render("klienci:", False, (255,255,255)) waiter = Agent(2,2)
display.blit(textsurface, (WIDTH*32 + 20, 300)) clientTime = 10
textsurface = font.render("czas:", False, (255,255,255)) totaltime = 0
display.blit(textsurface, (WIDTH*32 + 20, 332))
while True: clock = pygame.time.Clock()
for event in pygame.event.get(): ticks = 0
if event.type == pygame.KEYDOWN: #draw info
if event.key == pygame.K_F4: help = True
pygame.quit() if help:
if event.key == pygame.K_F5: font = pygame.font.SysFont('Arial', 18)
restaurant = Restaurant(3, 5) textsurface = font.render("kelner", False, (255,255,255))
waiter = Agent(2,2) pygame.draw.circle(display, (255,255,255), (WIDTH*32 + 26, 16), 16)
clientTime = 10 display.blit(textsurface, (WIDTH*32 + 50, 0))
ticks = 0 textsurface = font.render("sciana", False, (255,255,255))
totaltime = 0 pygame.draw.rect(display, (128,0,128), (WIDTH*32 + 10, 32, 32-1, 32-1))
if event.key == pygame.K_g: display.blit(textsurface, (WIDTH*32 + 50, 32))
t = random.choice(restaurant.tables) textsurface = font.render("stolik - pusty", False, (255,255,255))
waiter.BFS(t) pygame.draw.rect(display, (64,64,64), (WIDTH*32 + 10, 64, 32-1, 32-1))
if event.key == pygame.K_w: display.blit(textsurface, (WIDTH*32 + 50, 64))
waiter.walk() textsurface = font.render("stolik - decyduje", False, (255,255,255))
#update restaurant pygame.draw.rect(display, (0,128,0), (WIDTH*32 + 10, 96, 32-1, 32-1))
if restaurant.clients > 0: display.blit(textsurface, (WIDTH*32 + 50, 96))
clientTime = clientTime - 1 textsurface = font.render("stolik - zamawia", False, (255,255,255))
if clientTime == 0: pygame.draw.rect(display, (0,255,0), (WIDTH*32 + 10, 128, 32-1, 32-1))
clientTime = 10 display.blit(textsurface, (WIDTH*32 + 50, 128))
restaurant.putClient() textsurface = font.render("stolik - czeka", False, (255,255,255))
for t in restaurant.kitchen: pygame.draw.rect(display, (255,128,0), (WIDTH*32 + 10, 160, 32-1, 32-1))
if t[2]> 0: display.blit(textsurface, (WIDTH*32 + 50, 160))
t[2] = t[2] - 1 textsurface = font.render("stolik - je", False, (255,255,255))
pygame.draw.rect(display, (128,64,0), (WIDTH*32 + 10, 192, 32-1, 32-1))
display.blit(textsurface, (WIDTH*32 + 50, 192))
#update tables textsurface = font.render("kuchnia", False, (255,255,255))
for table in restaurant.tables: pygame.draw.rect(display, (255,0,255), (WIDTH*32 + 10, 224, 32-1, 32-1))
if restaurant.tiles[table[1]][table[0]].clientState: display.blit(textsurface, (WIDTH*32 + 50, 224))
if restaurant.tiles[table[1]][table[0]].clientState == "decide":
restaurant.tiles[table[1]][table[0]].client = restaurant.tiles[table[1]][table[0]].client - 1 textsurface = font.render("klienci:", False, (255,255,255))
if restaurant.tiles[table[1]][table[0]].client == 0: display.blit(textsurface, (WIDTH*32 + 20, 300))
restaurant.tiles[table[1]][table[0]].clientState = "order" textsurface = font.render("czas:", False, (255,255,255))
elif restaurant.tiles[table[1]][table[0]].clientState == "eat": display.blit(textsurface, (WIDTH*32 + 20, 332))
restaurant.tiles[table[1]][table[0]].client = restaurant.tiles[table[1]][table[0]].client - 1
if restaurant.tiles[table[1]][table[0]].client == 0: while True:
restaurant.tiles[table[1]][table[0]].clientState = False for event in pygame.event.get():
totaltime = totaltime + ticks if event.type == pygame.KEYDOWN:
restaurant.left = restaurant.left - 1 if event.key == pygame.K_F4:
if restaurant.left == 0: pygame.quit()
print("done in", totaltime) if event.key == pygame.K_F5:
file = open('results.csv', 'a') restaurant = Restaurant(3, 5)
file.write("\n") waiter = Agent(2,2)
file.write(str(S_IDLE.index(IDLE))) clientTime = 10
file.write(",") ticks = 0
file.write(str(S_FIRST.index(FIRST))) totaltime = 0
file.write(",") if event.key == pygame.K_g:
if totaltime > 1076: t = random.choice(restaurant.tables)
file.write(str(0)) waiter.BFS(t)
else: if event.key == pygame.K_w:
file.write(str(1)) waiter.walk()
file.close() #update restaurant
restaurant = Restaurant(3, 5) if restaurant.clients > 0:
waiter = Agent(2,2) clientTime = clientTime - 1
clientTime = 10 if clientTime == 0:
ticks = 0 clientTime = 10
totaltime = 0 restaurant.putClient()
IDLE = random.choice(S_IDLE) for t in restaurant.kitchen:
FIRST = random.choice(S_FIRST) if t[2]> 0:
t[2] = t[2] - 1
#update waiter
if waiter.idle: #update tables
if not waiter.getTask(): for table in restaurant.tables:
if not waiter.path: if restaurant.tiles[table[1]][table[0]].clientState:
if IDLE == "kitchen": if restaurant.tiles[table[1]][table[0]].clientState == "decide":
waiter.BFS(KITCHEN) restaurant.tiles[table[1]][table[0]].client = restaurant.tiles[table[1]][table[0]].client - 1
elif IDLE == "middle": if restaurant.tiles[table[1]][table[0]].client == 0:
waiter.BFS(MIDDLE) restaurant.tiles[table[1]][table[0]].clientState = "order"
else: elif restaurant.tiles[table[1]][table[0]].clientState == "eat":
waiter.wait() restaurant.tiles[table[1]][table[0]].client = restaurant.tiles[table[1]][table[0]].client - 1
else: if restaurant.tiles[table[1]][table[0]].client == 0:
waiter.walk() restaurant.tiles[table[1]][table[0]].clientState = False
elif waiter.path: totaltime = totaltime + ticks
waiter.walk() restaurant.left = restaurant.left - 1
if not waiter.orders and restaurant.tiles[waiter.y][waiter.x].clientState == "order" and not waiter.path: if restaurant.left == 0:
restaurant.tiles[waiter.y][waiter.x].clientState = "wait" print("done in", totaltime)
waiter.orders = (waiter.x, waiter.y) file = open('results.csv', 'a')
if (waiter.x, waiter.y) == KITCHEN: file.write("\n")
if waiter.orders: file.write(str(S_IDLE.index(IDLE)))
restaurant.kitchen.append([waiter.orders[0], waiter.orders[1], 50]) file.write(",")
waiter.orders = False file.write(str(S_FIRST.index(FIRST)))
elif not waiter.food: file.write(",")
for t in restaurant.kitchen: if totaltime > 1076:
if not t[2]: file.write(str(0))
waiter.BFS((t[0], t[1])) else:
restaurant.kitchen.remove(t) file.write(str(1))
waiter.food = True file.close()
waiter.idle = False restaurant = Restaurant(3, 5)
break waiter = Agent(2,2)
elif waiter.food and not waiter.path: clientTime = 10
restaurant.tiles[waiter.y][waiter.x].clientState = "eat" ticks = 0
restaurant.tiles[waiter.y][waiter.x].client = 30 totaltime = 0
waiter.food = False IDLE = random.choice(S_IDLE)
FIRST = random.choice(S_FIRST)
if ticks > 1500:
restaurant = Restaurant(3, 5)
waiter = Agent(2,2) #update waiter
clientTime = 10 if waiter.idle:
ticks = 0 if not waiter.getTask():
totaltime = 0 if not waiter.path:
IDLE = random.choice(S_IDLE) if IDLE == "kitchen":
FIRST = random.choice(S_FIRST) waiter.BFS(KITCHEN)
elif IDLE == "middle":
drawScreen() waiter.BFS(MIDDLE)
pygame.display.update() else:
clock.tick(1500) waiter.wait()
ticks = ticks + 1 else:
waiter.walk()
elif waiter.path:
waiter.walk()
if not waiter.orders and restaurant.tiles[waiter.y][waiter.x].clientState == "order" and not waiter.path:
restaurant.tiles[waiter.y][waiter.x].clientState = "wait"
waiter.orders = (waiter.x, waiter.y)
if (waiter.x, waiter.y) == KITCHEN:
if waiter.orders:
restaurant.kitchen.append([waiter.orders[0], waiter.orders[1], 50])
waiter.orders = False
elif not waiter.food:
for t in restaurant.kitchen:
if not t[2]:
waiter.BFS((t[0], t[1]))
restaurant.kitchen.remove(t)
waiter.food = True
waiter.idle = False
break
elif waiter.food and not waiter.path:
restaurant.tiles[waiter.y][waiter.x].clientState = "eat"
restaurant.tiles[waiter.y][waiter.x].client = 30
waiter.food = False
if ticks > 1500:
restaurant = Restaurant(3, 5)
waiter = Agent(2,2)
clientTime = 10
ticks = 0
totaltime = 0
IDLE = random.choice(S_IDLE)
FIRST = random.choice(S_FIRST)
drawScreen()
pygame.display.update()
clock.tick(1500)
ticks = ticks + 1