Merge branch 'master' of https://git.wmi.amu.edu.pl/s444426/AIProjekt
This commit is contained in:
commit
27cffed5d1
@ -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):
|
|
||||||
super().add_soil(soil)
|
|
||||||
self._starttime = datetime.now()
|
|
||||||
|
|
||||||
# zwraca czy zbierać rośline
|
# 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:
|
||||||
@ -28,11 +24,3 @@ class Beetroot(Plant):
|
|||||||
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
|
|
||||||
|
@ -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):
|
|
||||||
super().add_soil(soil)
|
|
||||||
self._starttime = datetime.now()
|
|
||||||
|
|
||||||
# zwraca czy zbierać rośline
|
# 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:
|
||||||
@ -28,11 +24,3 @@ class Cabbage(Plant):
|
|||||||
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
|
|
||||||
|
@ -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):
|
|
||||||
super().add_soil(soil)
|
|
||||||
self._starttime = datetime.now()
|
|
||||||
|
|
||||||
# zwraca czy zbierać rośline
|
# 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:
|
||||||
@ -28,11 +24,3 @@ class Carrot(Plant):
|
|||||||
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
|
|
||||||
|
@ -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)
|
@ -1,18 +1,13 @@
|
|||||||
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
|
|
||||||
# def __del__(self):
|
|
||||||
# self.leave_soil()
|
|
||||||
|
|
||||||
# to sie drukuje jak zapytamy o stworzony obiekt
|
# to sie drukuje jak zapytamy o stworzony obiekt
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -27,20 +22,12 @@ class Plant:
|
|||||||
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
|
||||||
|
|
||||||
@ -62,10 +49,4 @@ class Plant:
|
|||||||
# 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()
|
|
||||||
# a.plant_remove() #to bedzie metoda w klasie Soil, bedzie usuwac roslinke z gleby
|
|
||||||
self._soil = -1
|
self._soil = -1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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):
|
|
||||||
super().add_soil(soil)
|
|
||||||
self._starttime = datetime.now()
|
|
||||||
|
|
||||||
# zwraca czy zbierać rośline
|
# 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:
|
||||||
@ -28,11 +24,3 @@ class Pumpkin(Plant):
|
|||||||
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
|
|
||||||
|
@ -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._x = x
|
|
||||||
#self._y = y
|
|
||||||
self._plant = -1 # nowa gleba nie ma roślinki
|
self._plant = -1 # nowa gleba nie ma roślinki
|
||||||
self._dry = dry # procent wysuszenia gleby, tworząc nową jest nawodniona w 100%
|
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):
|
||||||
@ -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
|
Loading…
Reference in New Issue
Block a user