Sztuczna_Inteligencja_2020/main.py

81 lines
2.5 KiB
Python
Raw Normal View History

2020-04-27 21:56:17 +02:00
import secrets
import sys
2020-04-06 22:10:21 +02:00
2020-05-19 18:19:34 +02:00
from src.decisionTree import *
2020-05-24 21:15:56 +02:00
#from src.SubprojectMaksymilianKierski.PlateRecognition import use_model_to_predict
2020-04-06 22:10:21 +02:00
if __name__ == "__main__":
# SETUP
pygame.init()
clock = pygame.time.Clock()
graphics = Graphics()
waiter = Waiter(graphics)
2020-05-19 18:28:40 +02:00
tree = DecisionTree()
2020-04-06 22:10:21 +02:00
# init functions
graphics.drawBackground(waiter.matrix)
2020-04-29 11:12:18 +02:00
graphics.update(waiter)
2020-04-06 22:10:21 +02:00
2020-04-27 21:56:17 +02:00
goal = None
2020-04-29 11:12:18 +02:00
path = ''
2020-04-06 22:10:21 +02:00
while True:
2020-05-13 09:22:12 +02:00
2020-04-06 22:10:21 +02:00
for event in pygame.event.get():
2020-05-13 09:22:12 +02:00
# rabbit.check(waiter.matrix, waiter.X, waiter.Y)
2020-04-06 22:10:21 +02:00
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
2020-05-19 18:19:34 +02:00
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])
2020-05-19 18:19:34 +02:00
tree.print()
2020-04-06 22:10:21 +02:00
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:
print('hello')
2020-04-27 21:56:17 +02:00
if event.key == pygame.K_r:
temp = False
while not temp:
x = secrets.randbelow(graphics.width)
y = secrets.randbelow(graphics.height)
print(x, y)
2020-04-27 21:56:17 +02:00
if waiter.matrix.matrix[x][y].walk_through == 1:
temp = True
goal = (x, y)
path = waiter.findPath(goal)
2020-04-29 11:12:18 +02:00
path = waiter.translatePath(path)
2020-04-27 21:56:17 +02:00
2020-04-29 11:12:18 +02:00
if path != '':
nextStep = path[0]
path = path[1:]
2020-04-28 18:56:50 +02:00
waiter.travel(nextStep, graphics)
2020-04-06 22:10:21 +02:00
pygame.display.flip()
2020-05-13 09:22:12 +02:00
clock.tick(graphics.fps)