diff --git a/App.py b/App.py index f187b03..36f4428 100644 --- a/App.py +++ b/App.py @@ -119,7 +119,7 @@ def init_demo(): #Demo purpose if(TreeFlag): drzewo.treeLearn() drzewo.plotTree() - print("Decyzja to: ",drzewo.makeDecision([[10,60,0,1,0,20,1,20]])) + print("Decyzja to: ",drzewo.makeDecision([[10,60,0,1,1,0,20,1,20]])) #do moves and condtion cycles start_flag=False # demo_move() diff --git a/Climate.py b/Climate.py index 3733321..aa376db 100644 --- a/Climate.py +++ b/Climate.py @@ -1,40 +1,49 @@ +#THESE DICTIONARIES ARE USED FOR DISPLAY AND FOR DOCUMENTATION PURPOSES + seasons={ - 0:"winter", - 1:"spring", - 2:"summer", - 3:"fall"} + 0:"zima", + 1:"wiosna", + 2:"lato", + 3:"jesien"} time={ - 0:"morning", - 1:"noon", - 2:"afternoon", - 3:"night"} + 0:"rano", + 1:"poludnie", + 2:"wieczor", + 3:"noc"} -weather={ - 0:"perfect", - 1:"hot", - 2:"cold", - 3:"freezing", - 4:"rainy", - 5:"snowy", - 6:"storm"} +rain={ + 0:"brak", + 1:"lekki deszcz", + 2:"normalny deszcz", + 3:"ulewa" +} + +temperature={ + 0:"bardzo zimno", + 1:"zimno", + 2:"przecietnie", + 3:"cieplo", + 4:"upal",} def getNextSeason(season): - if(season=="winter"): - return seasons[1] - if(season=="spring"): - return seasons[2] - if(season=="summer"): - return seasons[3] - if(season=="fall"): - return seasons[0] + if(season==3): + return 0 + else: + return season+1 def getNextTime(currentTime): - if(currentTime=="morning"): - return time[1] - if(currentTime=="noon"): - return time[2] - if(currentTime=="afternoon"): - return time[3] - if(currentTime=="night"): - return time[0] \ No newline at end of file + if(currentTime==3): + return 0 + else: + return currentTime+1 + +def getAmount(type): + if(type=="seasons"): + return len(seasons) + if(type=="rain"): + return len(rain) + if(type=="time"): + return len(time) + if(type=="temperature"): + return len(temperature) \ No newline at end of file diff --git a/Condition.py b/Condition.py index 8a3ff1d..4cff640 100644 --- a/Condition.py +++ b/Condition.py @@ -5,34 +5,39 @@ class Condition: def __init__(self): self.season=self.setRandomSeason() self.currentTime=self.setRandomTime() - self.weather=self.setRandomWeather() + self.rain=self.setRandomRain() + self.temperature=self.setRandomRain() self.clock=0 def setRandomSeason(self): - return Climate.seasons[self.randomizer(3)] + return self.randomizer(Climate.getAmount("seasons")) def setRandomTime(self): - return Climate.time[self.randomizer(3)] + return self.randomizer(Climate.getAmount("time")) - def setRandomWeather(self): - return Climate.weather[self.randomizer(6)] + def setRandomRain(self): + return self.randomizer(Climate.getAmount("rain")) + def setRandomTemperature(self): + return self.randomizer(Climate.getAmount("temperature")) - def randomizer(self,maxIndex): - return random.randint(0,maxIndex) + def randomizer(self,max): + return random.randint(0,max-1) def cycle(self): if(self.clock==12): - self.currentTime=Climate.time[0] - self.weather=self.setRandomWeather() + self.currentTime=0 + self.rain=self.setRandomRain() + self.temperature=self.setRandomTemperature() self.season=Climate.getNextSeason(self.season) self.clock=0 return else: self.currentTime=Climate.getNextTime(self.currentTime) - self.weather=self.setRandomWeather() + self.rain=self.setRandomRain() + self.temperature=self.setRandomTemperature() self.clock=self.clock+1 def getCondition(self): - print(f"Aktualny czas: {self.currentTime},pogoda: {self.weather}, pora roku: {self.season}") + print(f"Aktualny czas: {Climate.time[self.currentTime]},opady: {Climate.rain[self.rain]},temperatura: {Climate.temperature[self.temperature]}, pora roku: {Climate.seasons[self.season]}") \ No newline at end of file diff --git a/Data/dataTree.csv b/Data/dataTree.csv index 20c09c2..08b4186 100644 --- a/Data/dataTree.csv +++ b/Data/dataTree.csv @@ -1,3 +1,3 @@ -plant_water_lever,tractor_water_lever,weather,season,current_time,growth,disease,fertility,action -80,60,0,1,0,20,1,20,0 -20,60,0,1,0,20,1,20,1 \ No newline at end of file +plant_water_level,tractor_water_level,temperature,rain,season,current_time,growth,disease,fertility,action +80,60,3,2,1,0,20,1,20,0 +20,60,3,0,1,0,20,1,20,1 \ No newline at end of file diff --git a/Drzewo.py b/Drzewo.py index 471b691..c883c1a 100644 --- a/Drzewo.py +++ b/Drzewo.py @@ -2,7 +2,7 @@ from sklearn import tree as skltree import pandas,os import matplotlib.pyplot as plt -atributes=['plant_water_lever','tractor_water_lever','weather','season','current_time','growth','disease','fertility'] #Columns in CSV file should be in the same order +atributes=['plant_water_level','tractor_water_level','temperature','rain','season','current_time','growth','disease','fertility'] #Columns in CSV file should be in the same order class Drzewo: def __init__(self): self.tree=self.treeLearn() diff --git a/Tractor.py b/Tractor.py index c9707df..a55fcc1 100644 --- a/Tractor.py +++ b/Tractor.py @@ -39,7 +39,7 @@ class Tractor: self.clock=clock self.slot_hydrate_dict={} self.bfs2_flag=bfs2_flag - + self.waterLevel=random.randint(0,100) def draw_tractor(self): self.screen.blit(self.current_tractor_image, (self.slot.x_axis * dCon.CUBE_SIZE, self.slot.y_axis * dCon.CUBE_SIZE))