Added button for the Miniproject + some updated graphics

Key '2' is responsed for a decision tree ordering
Commented graphics, have to add some extra frame for the Actor
This commit is contained in:
Serhii Hromov 2020-06-27 19:48:15 +00:00
parent 2dc065118f
commit d37efd29d7

21
main.py
View File

@ -91,7 +91,12 @@ MIDDLE = (floor(WIDTH / 2), floor(HEIGHT / 2))
display = pygame.display.set_mode((WIDTH * 32 + 200, HEIGHT * 32)) display = pygame.display.set_mode((WIDTH * 32 + 200, HEIGHT * 32))
tileFoil = pygame.image.load('tile.jpg') tileFoil = pygame.image.load('tile.jpg')
waiterAct = pygame.image.load('act1.png') waiterAct = pygame.image.load('act1.png')
waiterAct.set_colorkey((255, 255, 255)) tableEmpty = pygame.image.load('table.png')
tableOrder = pygame.image.load('tableOrder.png')
tableDecide = pygame.image.load('tableDecide.png')
tableWait = pygame.image.load('tableWait.png')
tableEat = pygame.image.load('tableEat.png')
wall = pygame.image.load('wall.png')
# eating time # eating time
EAT_TIME = 15 EAT_TIME = 15
@ -467,26 +472,31 @@ def drawScreen():
display.blit(tileFoil, (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) display.blit(tileFoil, (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
if tile.cost == 5: if tile.cost == 5:
pygame.draw.circle(display, (128, 128, 255), (iw * 32 + 17, ih * 32 + 17), 8) pygame.draw.circle(display, (128, 128, 255), (iw * 32 + 17, ih * 32 + 17), 8)
if tile.table: if tile.table:
if tile.clientState: if tile.clientState:
if tile.clientState == "decide": if tile.clientState == "decide":
pygame.draw.rect(display, (0, 128, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) pygame.draw.rect(display, (0, 128, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
#display.blit(tableDecide, (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
elif tile.clientState == "order": elif tile.clientState == "order":
pygame.draw.rect(display, (0, 255, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) pygame.draw.rect(display, (0, 255, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
#display.blit(tableOrder, (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
elif tile.clientState == "wait": elif tile.clientState == "wait":
pygame.draw.rect(display, (255, 128, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) pygame.draw.rect(display, (255, 128, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
#display.blit(tableWait, (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
elif tile.clientState == "eat": elif tile.clientState == "eat":
pygame.draw.rect(display, (128, 64, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) pygame.draw.rect(display, (128, 64, 0), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
#display.blit(tableEat, (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
else: else:
pygame.draw.rect(display, (64, 64, 64), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) pygame.draw.rect(display, (64, 64, 64), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
#display.blit(tableEmpty, (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
if tile.kitchen: if tile.kitchen:
pygame.draw.rect(display, (255, 0, 255), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) pygame.draw.rect(display, (255, 0, 255), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
# if tile.visited: # if tile.visited:
# pygame.draw.rect(display, (64,0,64), (iw * 32 + 1, ih * 32+1, 14, 14)) # pygame.draw.rect(display, (64,0,64), (iw * 32 + 1, ih * 32+1, 14, 14))
else: else:
pygame.draw.rect(display, (128, 0, 128), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1)) pygame.draw.rect(display, (128, 0, 128), (iw * 32 + 1, ih * 32 + 1, 32 - 1, 32 - 1))
#pygame.draw.circle(display, (255, 255, 255), (waiter.x * 32 + 16, waiter.y * 32 + 16), 16) pygame.draw.circle(display, (255, 255, 255), (waiter.x * 32 + 16, waiter.y * 32 + 16), 16)
display.blit(waiterAct, (waiter.x * 32 + 8, waiter.y * 32 + 8)) #display.blit(waiterAct, (waiter.x * 32 + 8, waiter.y * 32 + 8))
#1234 NWSE #1234 NWSE
xx = 0 xx = 0
yy = 0 yy = 0
@ -560,6 +570,9 @@ while True:
project = 0 project = 0
if event.key == pygame.K_1: if event.key == pygame.K_1:
project = 1 project = 1
#Execute project
if event.key == pygame.K_2:
print("Passed: %s. Prediction: %s" % (client_ordering(), print_leaf(classify(client_ordering(), tree))))
if event.key == pygame.K_F4: if event.key == pygame.K_F4:
pygame.quit() pygame.quit()
if event.key == pygame.K_F5: if event.key == pygame.K_F5: