import secrets import sys from random import randrange from src.decisionTree import * from src.SubprojectMaksymilianKierski.PlateRecognition import use_model_to_predict, text_speech if __name__ == "__main__": # SETUP pygame.init() clock = pygame.time.Clock() graphics = Graphics() waiter = Waiter(graphics) tree = DecisionTree() # init functions graphics.drawBackground(waiter.matrix) graphics.update(waiter) goal = None path = '' while True: for event in pygame.event.get(): # rabbit.check(waiter.matrix, waiter.X, waiter.Y) if event.type == pygame.QUIT: pygame.quit() sys.exit() break if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: pygame.quit() sys.exit() break if event.key == pygame.K_s: tree.TasksList('check', [10, 3]) tree.TasksList('eat', [5, 12]) tree.TasksList('order', [12, 4]) tree.TasksList('goToBar', [10, 10]) tree.TasksList('check', [3, 4]) tree.TasksList('eat', [10, 5]) tree.print() 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]) if not [waiter.X, waiter.Y] in tabPos: # save_dataset() x = tabPos[0][0] y = tabPos[0][1] goal = (x, y) path = waiter.findPath(goal) path = waiter.translatePath(path) else: predict = use_model_to_predict('test-{}'.format(randrange(20))) if predict == 1: predict = 'This plate is 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) pygame.display.flip() if event.key == pygame.K_r: temp = False while not temp: x = secrets.randbelow(graphics.width) y = secrets.randbelow(graphics.height) print(x, y) if waiter.matrix.matrix[x][y].walk_through == 1: temp = True goal = (x, y) path = waiter.findPath(goal) path = waiter.translatePath(path) if path != '': nextStep = path[0] path = path[1:] waiter.travel(nextStep, graphics) pygame.display.flip() clock.tick(graphics.fps)