FINAL2
This commit is contained in:
parent
bed9656adf
commit
9007ea7ae2
11
main.py
11
main.py
@ -12,7 +12,6 @@ from manualSteering import manualSteeringDriver
|
|||||||
import joblib
|
import joblib
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
|
|
||||||
@ -28,8 +27,9 @@ hitchCounter = 0
|
|||||||
loadCounter = 0
|
loadCounter = 0
|
||||||
toolCounter = - 1
|
toolCounter = - 1
|
||||||
|
|
||||||
|
#środowisko
|
||||||
board = Board.generate()
|
board = Board.generate()
|
||||||
|
#agent
|
||||||
tractor = Tractor(horizontal_index=-0, vertical_index=0, hitch="nothing", header=False, autodrive=True,
|
tractor = Tractor(horizontal_index=-0, vertical_index=0, hitch="nothing", header=False, autodrive=True,
|
||||||
direction="RIGHT")
|
direction="RIGHT")
|
||||||
|
|
||||||
@ -40,10 +40,12 @@ move_list = []
|
|||||||
|
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
|
#zjawiska pogodowe
|
||||||
weather, day_time, temperature, wind, humidy = WeatherConditions.checkConditions()
|
weather, day_time, temperature, wind, humidy = WeatherConditions.checkConditions()
|
||||||
|
|
||||||
weatherTimer = 0
|
weatherTimer = 0
|
||||||
|
|
||||||
|
#pętla główna działania programu
|
||||||
while working:
|
while working:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
@ -54,17 +56,20 @@ while working:
|
|||||||
|
|
||||||
field = board[tractor.horizontal_index][tractor.vertical_index]
|
field = board[tractor.horizontal_index][tractor.vertical_index]
|
||||||
|
|
||||||
if weatherTimer == 2:
|
if weatherTimer == 5:
|
||||||
weatherTimer = 0
|
weatherTimer = 0
|
||||||
weather, day_time, temperature, wind, humidy = WeatherConditions.checkConditions()
|
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)]
|
question = [convertToPrediction.convert(field.state, weather, day_time, temperature, wind, humidy)]
|
||||||
|
|
||||||
dtree = joblib.load('treedata\\DecisionTree.pkl')
|
dtree = joblib.load('treedata\\DecisionTree.pkl')
|
||||||
|
|
||||||
|
#przekazanie informacji do drzewa
|
||||||
decision = dtree.predict(question)
|
decision = dtree.predict(question)
|
||||||
|
|
||||||
if tractor.autodrive:
|
if tractor.autodrive:
|
||||||
|
# A*************
|
||||||
if not move_list and decision == 1:
|
if not move_list and decision == 1:
|
||||||
field.state = TractorAction.changeFieldState(field, tractor)
|
field.state = TractorAction.changeFieldState(field, tractor)
|
||||||
istate = graph.Istate(tractor.direction, tractor.horizontal_index, tractor.vertical_index)
|
istate = graph.Istate(tractor.direction, tractor.horizontal_index, tractor.vertical_index)
|
||||||
|
Loading…
Reference in New Issue
Block a user