Compare commits

..

4 Commits

6 changed files with 96 additions and 3 deletions

7
App.py
View File

@ -10,13 +10,13 @@ import Ui
import BFS import BFS
import AStar import AStar
import random import random
import Condition
bfs1_flag=False bfs1_flag=False
bfs2_flag=False #Change this lines to show different bfs implementation bfs2_flag=False #Change this lines to show different bfs implementation
bfs3_flag=False bfs3_flag=False
Astar = False Astar = False
Astar2 = True Astar2 = False
if bfs3_flag or Astar or Astar2: if bfs3_flag or Astar or Astar2:
Pole.stoneFlag = True Pole.stoneFlag = True
@ -35,6 +35,7 @@ ui=Ui.Ui(screen)
#Tractor creation #Tractor creation
traktor_slot = pole.get_slot_from_cord((0, 0)) traktor_slot = pole.get_slot_from_cord((0, 0))
traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.opryskiwacz,clock,bfs2_flag) traktor = Tractor.Tractor(traktor_slot, screen, Osprzet.opryskiwacz,clock,bfs2_flag)
condition=Condition.Condition()
def init_demo(): #Demo purpose def init_demo(): #Demo purpose
@ -117,6 +118,8 @@ def init_demo(): #Demo purpose
start_flag=False start_flag=False
# demo_move() # demo_move()
condition.cycle()
condition.getCondition()
old_info=get_info(old_info) old_info=get_info(old_info)
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:

40
Climate.py Normal file
View File

@ -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]

38
Condition.py Normal file
View File

@ -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}")

View File

@ -53,7 +53,10 @@ class Pole:
time.sleep(3) time.sleep(3)
#self.ui.render_text("Randomizing Crops") #self.ui.render_text("Randomizing Crops")
for coordinates in self.slot_dict: for coordinates in self.slot_dict:
if(coordinates==(0,0) or coordinates in stoneList or coordinates == self.gasStation): if(stoneFlag):
if( coordinates in stoneList or coordinates == self.gasStation ):
continue
if(coordinates==(0,0)):
continue continue
else: else:
self.slot_dict[coordinates].set_random_plant() self.slot_dict[coordinates].set_random_plant()

3
Tree.py Normal file
View File

@ -0,0 +1,3 @@
class Tree:
def __init__(self) -> None:
pass

6
readme.txt Normal file
View File

@ -0,0 +1,6 @@
Required packages:
pygame,matplotlib,sklearn
How to install:
pip install pygame
pip install matplotlib
pip install scikit-learn