Merge old branches to refactor due to merge it with master #22
@ -44,4 +44,4 @@ class Condition:
|
||||
|
||||
|
||||
def getCondition(self):
|
||||
print(f"Aktualny czas: {Climate.time[self.currentTime]},opady: {Climate.rain[self.rain]},temperatura: {Climate.temperature[self.temperature]}, pora roku: {Climate.seasons[self.season]}")
|
||||
return ([Climate.temperature[self.temperature],Climate.rain[self.rain],Climate.seasons[self.season],Climate.time[self.currentTime]])
|
||||
|
@ -23,6 +23,6 @@ class Drzewo:
|
||||
def makeDecision(self,values):
|
||||
action=self.tree.predict([values]) #0- nie podlewac, 1-podlewac
|
||||
if(action==[0]):
|
||||
return "Nie podlewac"
|
||||
return "Nie"
|
||||
if(action==[1]):
|
||||
return "Podlewac"
|
||||
return "Tak"
|
@ -117,4 +117,7 @@ class Roslina:
|
||||
return self.stan.return_hydrate()
|
||||
|
||||
def report_status(self):
|
||||
return f"Nazwa rosliny: {self.nazwa} "+self.stan.report_all()
|
||||
return f"Nazwa rosliny: {self.nazwa} "+self.stan.report_all()
|
||||
|
||||
def return_status_tree(self):
|
||||
return self.stan.return_stan_for_tree()
|
3
Stan.py
3
Stan.py
@ -62,4 +62,5 @@ class Stan:
|
||||
return [self.nawodnienie,self.wzrost,self.choroba,self.zyznosc]
|
||||
|
||||
def report_all(self):
|
||||
return f"Nawodnienie: {self.nawodnienie} Zyznosc: {self.zyznosc} Wzrost: {self.wzrost} Choroba: {self.return_disease_as_string()}"
|
||||
return f"Nawodnienie: {self.nawodnienie} Zyznosc: {self.zyznosc} Wzrost: {self.wzrost} Choroba: {self.return_disease_as_string()}"
|
||||
|
||||
|
33
Tractor.py
33
Tractor.py
@ -13,6 +13,8 @@ import Drzewo
|
||||
condition=Condition.Condition()
|
||||
drzewo=Drzewo.Drzewo()
|
||||
|
||||
format_string = "{:<25}{:<25}{:<25}{:<10}{:<10}{:<10}{:<25}{:<15}{:<20}{:<10}{:<15}"
|
||||
|
||||
|
||||
tab = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 0, 1, 0, 1, 1,
|
||||
@ -65,17 +67,22 @@ class Tractor:
|
||||
|
||||
def tree_move(self, pole):
|
||||
drzewo.treeLearn()
|
||||
print("test")
|
||||
drzewo.plotTree()
|
||||
self.snake_move_irrigation(pole, drzewo)
|
||||
|
||||
def get_attributes(self):
|
||||
slot_attributes=self.slot.return_stan_for_tree()
|
||||
climate_attributes=condition.return_condition()
|
||||
attributes=[]
|
||||
attributes=attributes+slot_attributes+[self.waterLevel]+climate_attributes
|
||||
print("Decyzja czy podlac:",drzewo.makeDecision(attributes),"Atrybuty tego stanu to:",attributes)
|
||||
self.snake_move_irrigation(pole, drzewo)
|
||||
#TODO SNAKE MOVE AND USING drzewo.makeDecision(attributes)for each slot. Also we need to cycle climate for each slot change
|
||||
#condition.cycle()
|
||||
#condition.getCondition()
|
||||
return attributes
|
||||
|
||||
def get_attributes_for_print(self):
|
||||
slot_attributes=self.slot.return_plant().return_status_tree()
|
||||
climate_attributes=condition.getCondition()
|
||||
slot_attributes=slot_attributes+[self.waterLevel]
|
||||
return slot_attributes+climate_attributes
|
||||
|
||||
def turn_right(self):
|
||||
# zmiana kierunku w prawo
|
||||
direction_map = {
|
||||
@ -157,16 +164,15 @@ class Tractor:
|
||||
|
||||
|
||||
def snake_move_irrigation(self, pole, drzewo):
|
||||
headers=['Wspolrzedne','Czy podlac','Poziom nawodnienia','Wzrost','Choroba','Zyznosc','Poziom wody w traktorze','Temperatura','Opady','Pora Roku','Aktualny czas']
|
||||
print(format_string.format(*headers))
|
||||
initPos = (self.slot.x_axis, self.slot.y_axis)
|
||||
counter = 0
|
||||
for i in range(initPos[1], dCon.NUM_Y):
|
||||
for j in range(initPos[0], dCon.NUM_X):
|
||||
slot_attributes=self.slot.return_stan_for_tree()
|
||||
climate_attributes=condition.return_condition()
|
||||
attributes=[]
|
||||
attributes=attributes+slot_attributes+[self.waterLevel]+climate_attributes
|
||||
attributes=self.get_attributes()
|
||||
decision = drzewo.makeDecision(attributes)
|
||||
print("Slot:", str("({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis),"Decyzja czy podlac:",decision,"Atrybuty slotu:",attributes)
|
||||
self.pretty_print_tree([str("({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis),decision,*self.get_attributes_for_print()])
|
||||
if decision == "Podlewac":
|
||||
self.slot.irrigatePlant()
|
||||
counter += 1
|
||||
@ -181,6 +187,7 @@ class Tractor:
|
||||
self.turn_left()
|
||||
self.move_forward(pole, False)
|
||||
self.turn_left()
|
||||
pygame.time.delay(50)
|
||||
print("podlanych slotów: ", str(counter))
|
||||
|
||||
def snake_move(self,pole,x,y):
|
||||
@ -227,9 +234,11 @@ class Tractor:
|
||||
print("- Typ:", akcja.typ)
|
||||
else:
|
||||
print("Brak akcji przypisanych do tego sprzętu.")
|
||||
|
||||
def pretty_print_tree(self,attributes):
|
||||
print(format_string.format(*attributes))
|
||||
def irrigateSlot(self):
|
||||
try:
|
||||
self.slot.irrigatePlant()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user