decision tree update
This commit is contained in:
parent
422d7adaac
commit
d91b9141fc
55
convertToPrediction.py
Normal file
55
convertToPrediction.py
Normal file
@ -0,0 +1,55 @@
|
||||
def convert(field_state, weather, day_time, temperature, wind, humidy):
|
||||
field_value = 0
|
||||
weather_value = 0
|
||||
day_time_value = 0
|
||||
temperature_value = 0
|
||||
wind_value = 0
|
||||
humidy_value = 0
|
||||
|
||||
if field_state == "toPlow":
|
||||
field_value = 0
|
||||
elif field_state == "toWater":
|
||||
field_value = 1
|
||||
elif field_state == "toSeed":
|
||||
field_value = 2
|
||||
elif field_state == "toFertilize":
|
||||
field_value = 3
|
||||
elif field_state == "toCut":
|
||||
field_value = 4
|
||||
|
||||
if weather == "Clear Sky":
|
||||
weather_value = 0
|
||||
elif weather == "Cloudy":
|
||||
weather_value = 1
|
||||
elif weather == "Rainy":
|
||||
weather_value = 2
|
||||
elif weather == "Hail":
|
||||
weather_value = 3
|
||||
|
||||
if day_time == "Night":
|
||||
day_time_value = 0
|
||||
elif day_time == "Day":
|
||||
day_time_value = 1
|
||||
|
||||
if temperature == "Freezing":
|
||||
temperature_value = 0
|
||||
elif temperature == "Cold":
|
||||
temperature_value = 1
|
||||
elif temperature == "Mild":
|
||||
temperature_value = 2
|
||||
elif temperature == "Hot":
|
||||
temperature_value = 3
|
||||
|
||||
if wind == "Windless":
|
||||
wind_value = 0
|
||||
elif wind == "Strong Wind":
|
||||
wind_value = 1
|
||||
elif wind == "Gale":
|
||||
wind_value = 2
|
||||
|
||||
if humidy == "Low":
|
||||
humidy_value = 0
|
||||
elif humidy == "High":
|
||||
humidy_value = 1
|
||||
|
||||
return field_value, weather_value, day_time_value, temperature_value, wind_value, humidy_value
|
7
main.py
7
main.py
@ -4,6 +4,7 @@ import Board
|
||||
import FindPath
|
||||
import TractorAction
|
||||
import WeatherConditions
|
||||
import convertToPrediction
|
||||
import drawUI
|
||||
import Graphsearch as graph
|
||||
from decisiontree import dtree
|
||||
@ -56,10 +57,10 @@ while working:
|
||||
weatherTimer = 0
|
||||
weather, day_time, temperature, wind, humidy = WeatherConditions.checkConditions()
|
||||
|
||||
#decision = dtree.predict([field.state, day_time, weather, temperature, wind, humidy])
|
||||
decision = 'Make Action'
|
||||
question = [convertToPrediction.convert(field.state, weather, day_time, temperature, wind, humidy)]
|
||||
decision = dtree.predict(question)
|
||||
|
||||
if not move_list and decision == 'Make Action':
|
||||
if not move_list and decision == 1:
|
||||
field.state = TractorAction.changeFieldState(field, tractor)
|
||||
istate = graph.Istate(tractor.direction, tractor.horizontal_index, tractor.vertical_index)
|
||||
move_list = graph.graphsearch([], [], istate, FindPath.nearestLookingField(board, tractor, TillageUnit), board)
|
||||
|
Loading…
Reference in New Issue
Block a user