This commit is contained in:
secret_dude 2021-06-22 23:27:36 +02:00
parent bed9656adf
commit 9007ea7ae2

11
main.py
View File

@ -12,7 +12,6 @@ from manualSteering import manualSteeringDriver
import joblib
import pygame
pygame.init()
@ -28,8 +27,9 @@ hitchCounter = 0
loadCounter = 0
toolCounter = - 1
#środowisko
board = Board.generate()
#agent
tractor = Tractor(horizontal_index=-0, vertical_index=0, hitch="nothing", header=False, autodrive=True,
direction="RIGHT")
@ -40,10 +40,12 @@ move_list = []
clock = pygame.time.Clock()
#zjawiska pogodowe
weather, day_time, temperature, wind, humidy = WeatherConditions.checkConditions()
weatherTimer = 0
#pętla główna działania programu
while working:
for event in pygame.event.get():
if event.type == pygame.QUIT:
@ -54,17 +56,20 @@ while working:
field = board[tractor.horizontal_index][tractor.vertical_index]
if weatherTimer == 2:
if weatherTimer == 5:
weatherTimer = 0
weather, day_time, temperature, wind, humidy = WeatherConditions.checkConditions()
#sformulowanie informacji dla drzewa decyzyjnego / lista informacji o aktualnej pogodzie i polu
question = [convertToPrediction.convert(field.state, weather, day_time, temperature, wind, humidy)]
dtree = joblib.load('treedata\\DecisionTree.pkl')
#przekazanie informacji do drzewa
decision = dtree.predict(question)
if tractor.autodrive:
# A*************
if not move_list and decision == 1:
field.state = TractorAction.changeFieldState(field, tractor)
istate = graph.Istate(tractor.direction, tractor.horizontal_index, tractor.vertical_index)