diff --git a/App.py b/App.py index 84bcc10..21f8131 100644 --- a/App.py +++ b/App.py @@ -10,7 +10,7 @@ import Ui import BFS import AStar import random - +import Condition bfs1_flag=False bfs2_flag=False #Change this lines to show different bfs implementation @@ -35,6 +35,7 @@ ui=Ui.Ui(screen) #Tractor creation traktor_slot = pole.get_slot_from_cord((0, 0)) traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.opryskiwacz,clock,bfs2_flag) +condition=Condition.Condition() def init_demo(): #Demo purpose @@ -117,6 +118,8 @@ def init_demo(): #Demo purpose start_flag=False # demo_move() + condition.cycle() + condition.getCondition() old_info=get_info(old_info) for event in pygame.event.get(): if event.type == pygame.QUIT: diff --git a/Climate.py b/Climate.py new file mode 100644 index 0000000..3733321 --- /dev/null +++ b/Climate.py @@ -0,0 +1,40 @@ +seasons={ + 0:"winter", + 1:"spring", + 2:"summer", + 3:"fall"} + +time={ + 0:"morning", + 1:"noon", + 2:"afternoon", + 3:"night"} + +weather={ + 0:"perfect", + 1:"hot", + 2:"cold", + 3:"freezing", + 4:"rainy", + 5:"snowy", + 6:"storm"} + +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] + +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 diff --git a/Condition.py b/Condition.py new file mode 100644 index 0000000..8a3ff1d --- /dev/null +++ b/Condition.py @@ -0,0 +1,38 @@ +import random +import Climate + +class Condition: + def __init__(self): + self.season=self.setRandomSeason() + self.currentTime=self.setRandomTime() + self.weather=self.setRandomWeather() + self.clock=0 + + def setRandomSeason(self): + return Climate.seasons[self.randomizer(3)] + + def setRandomTime(self): + return Climate.time[self.randomizer(3)] + + def setRandomWeather(self): + return Climate.weather[self.randomizer(6)] + + + def randomizer(self,maxIndex): + return random.randint(0,maxIndex) + + def cycle(self): + if(self.clock==12): + self.currentTime=Climate.time[0] + self.weather=self.setRandomWeather() + self.season=Climate.getNextSeason(self.season) + self.clock=0 + return + else: + self.currentTime=Climate.getNextTime(self.currentTime) + self.weather=self.setRandomWeather() + self.clock=self.clock+1 + + def getCondition(self): + print(f"Aktualny czas: {self.currentTime},pogoda: {self.weather}, pora roku: {self.season}") + \ No newline at end of file