Add random picking tables with plate prediction

This commit is contained in:
s450026 2020-05-25 14:59:50 +02:00
parent f7f3e5de84
commit 68a554e57e
5 changed files with 21 additions and 14 deletions

31
main.py
View File

@ -21,6 +21,7 @@ if __name__ == "__main__":
goal = None
path = ''
go = 0
while True:
for event in pygame.event.get():
@ -47,28 +48,34 @@ if __name__ == "__main__":
if event.key == pygame.K_m:
tabPos = [[1, 2], [1, 4], [1, 5], [1, 7], [1, 8], [1, 10], [5, 4], [5, 8]]
print(tabPos[0][0], tabPos[0][1])
tabPos = [[1, 2], [1, 5], [1, 8], [5, 8], [8, 2], [8, 5], [8, 8], [12, 3], [12, 7]]
rand = randrange(8)
if not [waiter.X, waiter.Y] in tabPos:
if not [waiter.X, waiter.Y] in tabPos or go == 0:
if [waiter.X, waiter.Y] in tabPos:
model = 'waiter_' + waiter.direction
graphics.clear(waiter.X, waiter.Y - 1)
# save_dataset()
x = tabPos[0][0]
y = tabPos[0][1]
x = tabPos[rand][0]
y = tabPos[rand][1]
goal = (x, y)
path = waiter.findPath(goal)
path = waiter.translatePath(path)
go = 1
else:
predict = use_model_to_predict('test-{}'.format(randrange(20)))
predict = use_model_to_predict('test-{}'.format(rand))
if predict == 1:
predict = 'This plate is empty'
predict = 'EMPTY'
else:
predict = 'This plate has food'
text_speech('arialnarrow.ttf', 30, predict, (255, 255, 255), (0, 128, 0),
(waiter.X*100), (waiter.Y*50), False, False, screen=graphics.screen)
predict = 'FOOD'
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
if event.key == pygame.K_r:
temp = False
while not temp:

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -138,7 +138,7 @@ def use_model_to_predict(name):
def text_speech(font: str, size: int, text: str, color, background, x, y, bold: bool, bubble: bool, screen):
global textRect
font = pygame.font.SysFont(None, 40)
font = pygame.font.SysFont(None, size)
#font = pygame.font.Font(font, size)
font.set_bold(bold)
textSurf = font.render(text, True, color).convert_alpha()