This commit is contained in:
MikeWMI 2020-06-09 15:59:18 +02:00
commit 27cffed5d1
7 changed files with 48 additions and 140 deletions

View File

@ -1,20 +1,16 @@
from plant_upgrade import Plant from plant_upgrade import Plant
from datetime import datetime from datetime import datetime
class Beetroot(Plant): class Beetroot(Plant):
def __init__(self, collect): def __init__(self, collect):
super().__init__('beetroot', collect) super().__init__('beetroot', collect)
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu self._wasFertilized = False # roslina nie byla nawozona przy tworzeniu
def add_soil(self, soil): # zwraca czy zbierać rośline
super().add_soil(soil)
self._starttime = datetime.now()
#zwraca czy zbierać rośline
def collect(self): def collect(self):
if self.have_soil(): if self.have_soil():
self.__growing()
if self._collect < 95: if self._collect < 95:
return 'False' return 'False'
elif 95 <= self._collect <= 115: elif 95 <= self._collect <= 115:
@ -22,17 +18,9 @@ class Beetroot(Plant):
elif self._collect > 115: elif self._collect > 115:
return 'Delete' return 'Delete'
#zwraca czy nawozić # zwraca czy nawozić
def fertillizing(self): def fertillizing(self):
if 35 <= self._collect <= 50: if 35 <= self._collect <= 50:
return True return True
else: else:
return False return False
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
def __growing(self):
checktime = datetime.now()
delta = checktime - self._starttime
a = delta // 40
# self._collect += a
self._starttime = checktime

View File

@ -1,20 +1,16 @@
from plant_upgrade import Plant from plant_upgrade import Plant
from datetime import datetime from datetime import datetime
class Cabbage(Plant): class Cabbage(Plant):
def __init__(self, collect): def __init__(self, collect):
super().__init__('cabbage', collect) super().__init__('cabbage', collect)
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu self._wasFertilized = False # roslina nie byla nawozona przy tworzeniu
def add_soil(self, soil): # zwraca czy zbierać rośline
super().add_soil(soil)
self._starttime = datetime.now()
#zwraca czy zbierać rośline
def collect(self): def collect(self):
if self.have_soil(): if self.have_soil():
self.__growing()
if self._collect < 85: if self._collect < 85:
return 'False' return 'False'
elif 85 <= self._collect <= 100: elif 85 <= self._collect <= 100:
@ -22,17 +18,9 @@ class Cabbage(Plant):
elif self._collect > 100: elif self._collect > 100:
return 'Delete' return 'Delete'
#zwraca czy nawozić # zwraca czy nawozić
def fertillizing(self): def fertillizing(self):
if 30 <= self._collect <= 45: if 30 <= self._collect <= 45:
return True return True
else: else:
return False return False
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
def __growing(self):
checktime = datetime.now()
delta = checktime - self._starttime
a = delta // 70
#self._collect += a
self._starttime = checktime

View File

@ -1,20 +1,16 @@
from plant_upgrade import Plant from plant_upgrade import Plant
from datetime import datetime from datetime import datetime
class Carrot(Plant): class Carrot(Plant):
def __init__(self, collect): def __init__(self, collect):
super().__init__('carrot', collect) super().__init__('carrot', collect)
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu self._wasFertilized = False # roslina nie byla nawozona przy tworzeniu
def add_soil(self, soil): # zwraca czy zbierać rośline
super().add_soil(soil)
self._starttime = datetime.now()
#zwraca czy zbierać rośline
def collect(self): def collect(self):
if self.have_soil(): if self.have_soil():
self.__growing()
if self._collect < 90: if self._collect < 90:
return 'False' return 'False'
elif 90 <= self._collect <= 105: elif 90 <= self._collect <= 105:
@ -22,17 +18,9 @@ class Carrot(Plant):
elif self._collect > 105: elif self._collect > 105:
return 'Delete' return 'Delete'
#zwraca czy nawozić # zwraca czy nawozić
def fertillizing(self): def fertillizing(self):
if 30 <= self._collect <= 50: if 30 <= self._collect <= 50:
return True return True
else: else:
return False return False
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
def __growing(self):
checktime = datetime.now()
delta = checktime - self._starttime
a = delta // 60
# self._collect += a
self._starttime = checktime

View File

@ -26,7 +26,7 @@ def decide_to_plant(soil):
# Roślina jest gotowa do zbioru lub ziemia jest wolna # Roślina jest gotowa do zbioru lub ziemia jest wolna
predicted = predict_data(data) predicted = predict_data(data)
# grow_a_plant(soil,predicted[0][0]) grow_a_plant(soil, predicted[0][0])
return predicted return predicted
@ -34,7 +34,6 @@ def decide_to_plant(soil):
def grow_a_plant(soil, plant_name): def grow_a_plant(soil, plant_name):
plant = Plant(plant_name) plant = Plant(plant_name)
soil.add_plant(plant) soil.add_plant(plant)
print(soil)
def get_info(soil): def get_info(soil):
@ -95,4 +94,4 @@ for soil in all_soil:
result.append([soil.get_pH(), soil.get_dry_level(), plant, collect, p[0]]) result.append([soil.get_pH(), soil.get_dry_level(), plant, collect, p[0]])
result = pd.DataFrame(data=result, columns=['pH', 'dry level', 'plant', 'ripe', 'prediction']) result = pd.DataFrame(data=result, columns=['pH', 'dry level', 'plant', 'ripe', 'prediction'])
print(result) #print(result)

View File

@ -1,45 +1,32 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
class Plant: class Plant:
#tworzymy jakas rosline co ma nazwe i id. ID powiedzmy ze buraki beda mialy 1, marchewki 2 itd. gleby powiedzmy tez damy 4 i beda mialy id 5-8
def __init__(self, name, collect=0): def __init__(self, name, collect=0):
super().__init__() super().__init__()
self._soil = -1 #jak tworzymy rosline to nie bedzie ona miala gleby self._soil = -1 # jak tworzymy rosline to nie bedzie ona miala gleby
self._name = name #to nazwa rosliny będzie np. burak1 self._name = name # to nazwa rosliny będzie np. burak
#self._id = ID #id rosliny buraki bedą mialy 1, i po tym inne obiekty beda rozpoznawac ten obiekt self._collect = collect # nowa roslina jest domyślnie w 0% dojrzala
self._collect = collect #nowa roslina jest w 0% dojrzala
#to jest jakbysmy usuneli obiekt. zabezpieczenie, zeby gleba pozniej byla wolna # to sie drukuje jak zapytamy o stworzony obiekt
# def __del__(self):
# self.leave_soil()
#to sie drukuje jak zapytamy o stworzony obiekt
def __str__(self): def __str__(self):
return f'Plant: {self._name}, Soil: {self._soil}, Status: {self.collect()}' return f'Plant: {self._name}, Soil: {self._soil}, Status: {self.collect()}'
#metoda abstrakcyjna, kazda roslina ma inny czas rosniecia wiec pass # metoda abstrakcyjna, kazda roslina ma inny czas rosniecia wiec pass
@abstractmethod @abstractmethod
def collect(self): def collect(self):
pass pass
@abstractmethod @abstractmethod
def fertillizing(self): def fertillizing(self):
pass pass
@abstractmethod
def growing(self):
pass
#pobieramy wspolrzedne roslinki # pobieramy wspolrzedne roslinki
def get_coordinates(self): def get_coordinates(self):
if self.have_soil(): if self.have_soil():
a = self.get_soil() a = self.get_soil()
a.get_coordinates(self) #get coordinates jest metoda w glebie a.get_coordinates(self) # get coordinates jest metoda w glebie
#pobieramy id roślinki
def get_id(self):
return self._id
def get_name(self): def get_name(self):
return self._name return self._name
@ -47,25 +34,19 @@ class Plant:
def get_collect(self): def get_collect(self):
return self._collect return self._collect
#dodajemy glebe # dodajemy glebe
def add_soil(self, soil): def add_soil(self, soil):
self._soil = soil self._soil = soil
#zwraca czy roslinka znajduje sie w ziemii obecnie - jak nie ma gleby to znaczy ze nie jest zasadzona jeszcze albo już. # zwraca czy roslinka znajduje sie w ziemii obecnie - jak nie ma gleby to znaczy ze nie jest zasadzona jeszcze albo już.
def have_soil(self): def have_soil(self):
return self._soil is not -1 return self._soil is not -1
#pobieramy jaka ma glebe, gleba tutaj będzie obiektem # pobieramy jaka ma glebe, gleba tutaj będzie obiektem
def get_soil(self): def get_soil(self):
return self._soil return self._soil
#to w przypadku jak bedziemy wyciagac z ziemii roslinke # to w przypadku jak bedziemy wyciagac z ziemii roslinke
def leave_soil(self): def leave_soil(self):
if self.have_soil(): if self.have_soil():
# a = self.get_soil() self._soil = -1
# a.plant_remove() #to bedzie metoda w klasie Soil, bedzie usuwac roslinke z gleby
self._soil = -1

View File

@ -1,20 +1,16 @@
from plant_upgrade import Plant from plant_upgrade import Plant
from datetime import datetime from datetime import datetime
class Pumpkin(Plant): class Pumpkin(Plant):
def __init__(self, collect): def __init__(self, collect):
super().__init__('pumpkin', collect) super().__init__('pumpkin', collect)
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu self._wasFertilized = False # roslina nie byla nawozona przy tworzeniu
def add_soil(self, soil): # zwraca czy zbierać rośline
super().add_soil(soil)
self._starttime = datetime.now()
#zwraca czy zbierać rośline
def collect(self): def collect(self):
if self.have_soil(): if self.have_soil():
self.__growing()
if self._collect < 90: if self._collect < 90:
return 'False' return 'False'
elif 90 <= self._collect <= 110: elif 90 <= self._collect <= 110:
@ -22,17 +18,9 @@ class Pumpkin(Plant):
elif self._collect > 110: elif self._collect > 110:
return 'Delete' return 'Delete'
#zwraca czy nawozić # zwraca czy nawozić
def fertillizing(self): def fertillizing(self):
if 20 <= self._collect <= 45: if 20 <= self._collect <= 45:
return True return True
else: else:
return False return False
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
def __growing(self):
checktime = datetime.now()
delta = checktime - self._starttime
a = delta // 50
# self._collect += a
self._starttime = checktime

View File

@ -1,34 +1,19 @@
from datetime import datetime from datetime import datetime
class Soil: class Soil:
def __init__(self, pH, dry): def __init__(self, pH, dry):
super().__init__() super().__init__()
#self._id = ID self._plant = -1 # nowa gleba nie ma roślinki
#self._x = x self._dry = dry # procent wysuszenia gleby, tworząc nową jest nawodniona w 100%
#self._y = y
self._plant = -1 #nowa gleba nie ma roślinki
self._dry = dry #procent wysuszenia gleby, tworząc nową jest nawodniona w 100%
self._pH = pH self._pH = pH
self._starttime = datetime.now()
# def __del__(self):
# self.plant_remove()
def __str__(self): def __str__(self):
if self.have_plant(): if self.have_plant():
return f'pH={self._pH}, dry level={self._dry}, plant={self.get_plant().get_name()}' return f'pH={self._pH}, dry level={self._dry}, plant={self.get_plant().get_name()}'
else: else:
return f'soil: pH={self._pH}, dry level={self._dry}, plant=none' return f'soil: pH={self._pH}, dry level={self._dry}, plant=none'
#return f'{self._x}, {self._y}), Plant: {self._plant}'
# współrzędne pola
def get_coordinates(self):
return self._x, self._y
# id gleby
def get_id(self):
return self._id
# zasadzenie roślinki # zasadzenie roślinki
def add_plant(self, plant): def add_plant(self, plant):
@ -39,7 +24,7 @@ class Soil:
# zwraca czy w ziemi znajduje się roślinka # zwraca czy w ziemi znajduje się roślinka
def have_plant(self): def have_plant(self):
return self._plant != -1 return self._plant != -1
# zwraca roślinkę znajdującą się w ziemii # zwraca roślinkę znajdującą się w ziemii
def get_plant(self): def get_plant(self):
return self._plant return self._plant
@ -50,7 +35,7 @@ class Soil:
def get_dry_level(self): def get_dry_level(self):
return self._dry return self._dry
#sprawdza w ilu procentach ziemia jest sucha # sprawdza w ilu procentach ziemia jest sucha
def is_dry(self): def is_dry(self):
self.__drying() self.__drying()
if self._dry < 30: if self._dry < 30:
@ -60,19 +45,10 @@ class Soil:
else: else:
return 'True' return 'True'
#metoda wysuszajaca ziemie. dodaje wysuszenie do ziemi, wywolywana w momencie sprawdzania czy ziemia jest sucha
def __drying(self):
checktime = datetime.now()
delta = checktime - self._starttime
a = delta //60
self._dry += a
self._starttime = checktime
self.__is_dry()
# usuwa roślinkę z ziemi i ją zwraca # usuwa roślinkę z ziemi i ją zwraca
def plant_remove(self): def plant_remove(self):
if self.have_plant(): if self.have_plant():
a = self.get_plant() a = self.get_plant()
a.leave_soil() a.leave_soil()
self._plant = -1 self._plant = -1
return a