Compare commits
6 Commits
7c7a485d6b
...
971746a0f8
Author | SHA1 | Date | |
---|---|---|---|
971746a0f8 | |||
afae656d76 | |||
9ebac46bef | |||
0b494d694d | |||
3713ccc8ff | |||
|
7a14a94b1e |
@ -26,7 +26,7 @@ class Condition:
|
|||||||
return random.randint(0,max-1)
|
return random.randint(0,max-1)
|
||||||
|
|
||||||
def cycle(self):
|
def cycle(self):
|
||||||
if(self.clock==12):
|
if(self.clock==11):
|
||||||
self.currentTime=0
|
self.currentTime=0
|
||||||
self.rain=self.setRandomRain()
|
self.rain=self.setRandomRain()
|
||||||
self.temperature=self.setRandomTemperature()
|
self.temperature=self.setRandomTemperature()
|
||||||
@ -44,4 +44,4 @@ class Condition:
|
|||||||
|
|
||||||
|
|
||||||
def getCondition(self):
|
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]])
|
||||||
|
248
Data/dataTree2.csv
Normal file
248
Data/dataTree2.csv
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
plant_water_level,growth,disease,fertility,tractor_water_level,temperature,rain,season,current_time,action
|
||||||
|
1,20,0,40,60,2,0,2,1,1
|
||||||
|
20,40,0,40,60,2,0,2,1,1
|
||||||
|
87,20,0,40,60,2,0,2,1,0
|
||||||
|
27,43,1,40,60,2,0,2,1,0
|
||||||
|
89,56,1,40,60,2,1,1,1,0
|
||||||
|
67,100,1,37,55,1,3,3,3,0
|
||||||
|
67,40,1,87,90,4,0,1,0,0
|
||||||
|
1,20,0,40,60,2,0,0,1,0
|
||||||
|
20,40,0,40,60,2,0,0,1,0
|
||||||
|
87,20,0,56,45,2,0,0,2,0
|
||||||
|
27,43,1,40,60,2,0,0,3,0
|
||||||
|
89,56,1,40,89,2,1,0,1,0
|
||||||
|
67,100,1,37,55,1,3,0,3,0
|
||||||
|
67,40,1,87,90,4,0,0,0,0
|
||||||
|
1,100,0,45,20,2,0,2,1,0
|
||||||
|
20,100,0,40,34,0,1,2,0,0
|
||||||
|
87,100,0,56,60,2,0,1,1,0
|
||||||
|
27,100,0,89,67,1,2,2,2,0
|
||||||
|
89,100,0,40,60,2,1,1,1,0
|
||||||
|
76,100,0,37,55,1,3,3,3,0
|
||||||
|
67,100,0,87,90,4,0,1,0,0
|
||||||
|
1,20,0,40,0,2,0,2,1,0
|
||||||
|
20,40,0,40,0,2,0,2,1,0
|
||||||
|
87,20,0,40,0,2,0,2,1,0
|
||||||
|
27,43,1,40,0,2,0,2,1,0
|
||||||
|
89,56,1,40,0,2,1,1,1,0
|
||||||
|
67,100,1,37,0,1,3,3,3,0
|
||||||
|
67,40,1,87,0,4,0,1,0,0
|
||||||
|
1,20,0,40,0,2,0,0,1,0
|
||||||
|
20,40,0,40,0,2,0,0,1,0
|
||||||
|
87,20,0,56,0,2,0,0,2,0
|
||||||
|
27,43,1,40,0,2,0,0,3,0
|
||||||
|
89,56,1,40,0,2,1,0,1,0
|
||||||
|
67,100,1,37,0,1,3,0,3,0
|
||||||
|
67,40,1,87,0,4,0,0,0,0
|
||||||
|
1,100,0,45,0,2,0,2,1,0
|
||||||
|
20,100,0,40,0,0,1,2,0,0
|
||||||
|
87,100,0,56,0,2,0,1,1,0
|
||||||
|
27,100,0,89,0,1,2,2,2,0
|
||||||
|
89,100,0,40,0,2,1,1,1,0
|
||||||
|
76,100,0,37,0,1,3,3,3,0
|
||||||
|
67,100,0,87,0,4,0,1,0,0
|
||||||
|
1,45,0,56,44,2,1,1,1,1
|
||||||
|
20,55,0,43,34,2,0,2,2,1
|
||||||
|
15,23,0,23,26,2,1,3,3,1
|
||||||
|
45,67,0,12,67,3,0,1,0,1
|
||||||
|
59,88,0,34,87,3,0,2,1,1
|
||||||
|
32,32,0,32,90,3,0,3,2,1
|
||||||
|
44,43,0,19,27,2,0,1,3,1
|
||||||
|
33,11,0,28,76,2,0,2,0,1
|
||||||
|
54,90,0,44,5,3,0,3,1,1
|
||||||
|
21,76,0,50,25,3,1,1,2,1
|
||||||
|
29,64,0,38,36,2,0,2,3,1
|
||||||
|
11,54,0,65,44,3,1,1,2,1
|
||||||
|
23,55,0,34,43,3,0,2,1,1
|
||||||
|
51,32,0,32,62,3,1,3,3,1
|
||||||
|
54,76,0,21,76,2,0,1,2,1
|
||||||
|
95,88,0,43,78,2,0,2,1,0
|
||||||
|
23,23,0,23,9,2,0,3,3,1
|
||||||
|
44,34,0,91,72,3,0,1,0,1
|
||||||
|
33,11,0,82,67,3,0,2,2,1
|
||||||
|
45,9,0,44,50,2,0,3,3,1
|
||||||
|
21,67,0,50,52,2,1,1,0,1
|
||||||
|
92,46,0,83,63,3,0,2,1,0
|
||||||
|
20,55,1,43,34,0,0,2,2,0
|
||||||
|
15,23,1,23,26,0,1,3,3,0
|
||||||
|
45,67,1,12,67,0,0,1,0,0
|
||||||
|
59,88,1,34,87,0,0,2,1,0
|
||||||
|
32,32,0,32,90,0,0,3,2,0
|
||||||
|
44,43,0,19,27,4,0,1,3,0
|
||||||
|
33,11,0,28,76,4,0,2,0,0
|
||||||
|
54,90,0,44,5,4,0,3,1,0
|
||||||
|
21,76,0,50,25,4,1,1,2,0
|
||||||
|
29,64,0,38,36,4,0,2,3,0
|
||||||
|
11,54,0,65,44,0,1,1,2,0
|
||||||
|
23,55,0,34,43,0,0,2,1,0
|
||||||
|
51,32,0,32,62,0,1,3,3,0
|
||||||
|
80,76,1,39,7,3,0,1,0,0
|
||||||
|
98,77,0,15,91,1,3,2,3,0
|
||||||
|
3,48,1,73,41,2,2,0,3,0
|
||||||
|
20,15,1,97,87,4,1,2,1,0
|
||||||
|
93,6,0,37,0,0,1,0,1,0
|
||||||
|
4,31,0,1,5,2,3,1,2,0
|
||||||
|
42,52,0,33,19,3,2,3,0,0
|
||||||
|
76,43,0,77,18,4,0,0,3,0
|
||||||
|
31,13,1,21,42,0,1,2,3,0
|
||||||
|
96,65,1,63,35,1,3,3,2,0
|
||||||
|
29,39,0,40,37,3,3,0,0,0
|
||||||
|
82,53,0,55,9,0,1,3,2,0
|
||||||
|
21,35,0,58,1,1,2,2,0,0
|
||||||
|
92,98,0,69,16,3,0,0,1,0
|
||||||
|
34,23,0,95,2,2,3,0,3,0
|
||||||
|
36,28,0,62,22,0,1,1,1,0
|
||||||
|
66,88,1,10,85,3,1,2,3,0
|
||||||
|
53,51,0,79,90,2,2,3,2,0
|
||||||
|
9,74,0,60,4,4,1,2,3,1
|
||||||
|
17,0,0,38,58,1,2,3,0,0
|
||||||
|
12,76,0,50,25,3,1,1,2,1
|
||||||
|
92,64,0,38,36,2,0,2,3,0
|
||||||
|
11,54,0,65,44,3,1,1,2,1
|
||||||
|
32,55,0,34,43,3,0,2,1,1
|
||||||
|
15,32,0,32,62,3,1,3,3,1
|
||||||
|
45,76,0,21,76,2,0,1,2,1
|
||||||
|
59,88,0,43,78,2,0,2,1,1
|
||||||
|
32,23,0,23,9,2,0,3,3,1
|
||||||
|
14,34,0,91,72,3,0,1,0,1
|
||||||
|
13,11,0,82,67,3,0,2,2,1
|
||||||
|
45,9,0,44,50,2,0,3,3,1
|
||||||
|
21,67,0,50,52,2,1,1,0,1
|
||||||
|
92,46,0,83,63,3,0,2,1,0
|
||||||
|
2,40,1,34,43,1,3,2,2,0
|
||||||
|
51,32,1,32,62,2,1,3,3,0
|
||||||
|
54,76,1,21,76,3,0,1,0,0
|
||||||
|
98,38,0,50,44,4,0,1,0,0
|
||||||
|
63,7,0,93,79,2,0,2,1,1
|
||||||
|
91,59,0,94,24,4,0,3,2,0
|
||||||
|
11,49,0,54,76,2,0,1,3,1
|
||||||
|
33,31,0,59,39,3,0,1,3,1
|
||||||
|
28,50,0,26,0,4,0,2,2,0
|
||||||
|
54,83,0,36,0,3,0,2,1,0
|
||||||
|
49,78,0,68,0,2,0,3,2,0
|
||||||
|
59,21,0,43,100,1,0,3,2,1
|
||||||
|
1,30,0,52,100,2,0,0,3,0
|
||||||
|
60,9,0,40,40,3,0,0,3,0
|
||||||
|
85,94,0,87,85,4,0,1,3,0
|
||||||
|
79,68,0,56,90,1,0,2,2,1
|
||||||
|
75,22,0,25,95,1,0,3,2,1
|
||||||
|
100,51,0,33,12,0,0,2,2,0
|
||||||
|
90,70,0,71,81,0,0,2,1,0
|
||||||
|
47,26,0,6,78,4,0,1,1,1
|
||||||
|
14,89,0,70,18,4,0,1,0,1
|
||||||
|
99,19,0,74,91,2,0,3,0,0
|
||||||
|
18,48,0,15,32,2,0,3,0,1
|
||||||
|
5,57,0,14,34,0,1,1,3,1
|
||||||
|
22,67,0,9,5,0,1,2,2,0
|
||||||
|
95,81,0,46,86,1,1,3,1,0
|
||||||
|
39,65,0,84,0,1,1,0,0,0
|
||||||
|
84,75,0,30,0,2,1,1,1,0
|
||||||
|
86,41,0,2,67,2,1,2,2,0
|
||||||
|
64,53,0,53,47,1,1,3,3,1
|
||||||
|
69,61,0,0,73,2,1,0,0,0
|
||||||
|
94,40,1,0,18,3,1,1,2,0
|
||||||
|
62,82,1,20,50,4,1,2,3,0
|
||||||
|
57,1,1,17,92,0,1,3,2,0
|
||||||
|
80,35,1,58,45,0,0,3,1,0
|
||||||
|
30,47,1,8,47,1,0,2,1,0
|
||||||
|
82,32,0,99,39,1,3,1,3,0
|
||||||
|
20,84,0,0,51,2,3,2,3,0
|
||||||
|
42,88,0,0,54,2,2,2,0,0
|
||||||
|
66,45,0,91,10,3,2,1,0,0
|
||||||
|
81,14,0,19,55,3,0,1,2,1
|
||||||
|
74,37,0,88,78,4,0,3,2,1
|
||||||
|
89,99,0,100,60,4,0,3,3,0
|
||||||
|
15,20,0,45,11,0,0,1,3,1
|
||||||
|
92,28,0,85,90,2,0,1,1,0
|
||||||
|
55,4,0,13,95,2,0,2,1,1
|
||||||
|
2,6,0,35,0,2,0,2,0,0
|
||||||
|
61,56,0,90,0,2,0,3,0,0
|
||||||
|
76,11,0,61,10,3,0,3,1,1
|
||||||
|
26,80,0,57,9,3,0,1,2,1
|
||||||
|
40,44,0,81,8,3,0,2,3,1
|
||||||
|
50,66,0,23,7,3,0,3,0,1
|
||||||
|
48,15,0,77,6,2,0,0,1,0
|
||||||
|
11,54,0,65,44,3,3,1,2,0
|
||||||
|
23,55,0,34,43,3,3,2,1,0
|
||||||
|
51,32,0,32,62,3,3,3,3,0
|
||||||
|
54,76,0,21,76,2,3,1,2,0
|
||||||
|
95,88,0,43,78,2,3,2,1,0
|
||||||
|
23,23,0,23,9,2,3,3,3,0
|
||||||
|
44,34,0,91,72,3,3,1,0,0
|
||||||
|
33,11,0,82,67,3,3,2,2,0
|
||||||
|
45,9,0,44,50,2,3,3,3,0
|
||||||
|
21,67,0,50,52,2,3,1,0,0
|
||||||
|
92,46,0,83,63,3,3,2,1,0
|
||||||
|
20,55,1,43,34,0,3,2,2,0
|
||||||
|
15,23,1,23,26,0,3,3,3,0
|
||||||
|
45,67,1,12,67,0,3,1,0,0
|
||||||
|
59,88,1,34,87,0,3,2,1,0
|
||||||
|
32,32,0,32,90,0,3,3,2,0
|
||||||
|
1,60,0,55,11,0,1,0,0,1
|
||||||
|
2,70,0,44,12,1,1,0,1,1
|
||||||
|
3,44,0,11,13,2,1,0,2,1
|
||||||
|
4,55,0,34,66,3,0,0,3,1
|
||||||
|
5,66,0,90,77,0,0,1,2,1
|
||||||
|
6,22,0,89,88,0,0,2,2,1
|
||||||
|
7,1,0,45,9,0,1,2,3,1
|
||||||
|
8,2,0,34,22,3,1,2,3,1
|
||||||
|
9,3,0,56,34,3,1,0,1,1
|
||||||
|
10,6,0,78,5,3,0,3,1,1
|
||||||
|
11,8,0,36,67,2,0,0,0,1
|
||||||
|
12,59,0,57,23,2,1,1,0,1
|
||||||
|
13,67,0,29,34,1,1,0,1,1
|
||||||
|
14,20,0,30,90,1,1,2,2,1
|
||||||
|
15,21,0,66,89,0,1,3,3,1
|
||||||
|
44,100,0,91,72,3,3,1,0,0
|
||||||
|
33,100,0,82,67,3,3,2,2,0
|
||||||
|
45,100,0,44,50,2,3,3,3,0
|
||||||
|
21,100,0,50,52,2,3,1,0,0
|
||||||
|
92,100,0,83,63,3,3,2,1,0
|
||||||
|
20,100,1,43,34,0,3,2,2,0
|
||||||
|
15,100,1,23,26,0,3,3,3,0
|
||||||
|
45,100,1,12,67,0,3,1,0,0
|
||||||
|
59,100,1,34,87,0,3,2,1,0
|
||||||
|
32,100,0,32,90,0,3,3,2,0
|
||||||
|
1,100,0,55,11,0,1,0,0,0
|
||||||
|
2,100,0,44,12,1,1,0,1,0
|
||||||
|
3,100,0,11,13,2,1,0,2,0
|
||||||
|
4,100,0,34,66,3,0,0,3,0
|
||||||
|
5,100,0,90,77,0,0,1,2,0
|
||||||
|
6,100,0,89,88,0,0,2,2,0
|
||||||
|
7,100,0,45,9,0,1,2,3,0
|
||||||
|
8,100,0,34,22,3,1,2,3,0
|
||||||
|
9,100,0,56,34,3,1,0,1,0
|
||||||
|
10,100,0,78,5,3,0,3,1,0
|
||||||
|
11,100,0,36,67,2,0,0,0,0
|
||||||
|
12,100,0,57,23,2,1,1,0,0
|
||||||
|
13,100,0,29,34,1,1,0,1,0
|
||||||
|
14,100,0,30,90,1,1,2,2,0
|
||||||
|
15,100,0,66,89,0,1,3,3,0
|
||||||
|
1,6,0,5,10,4,1,1,3,1
|
||||||
|
2,7,0,4,20,4,1,2,2,1
|
||||||
|
3,4,0,11,30,4,1,3,1,1
|
||||||
|
4,5,0,43,5,2,0,1,2,1
|
||||||
|
5,6,0,9,17,2,0,2,1,1
|
||||||
|
6,2,0,98,18,4,0,3,1,1
|
||||||
|
7,11,0,54,19,4,1,0,2,1
|
||||||
|
8,20,0,43,22,4,1,1,1,1
|
||||||
|
9,30,0,65,43,4,1,2,3,1
|
||||||
|
10,60,0,87,50,1,0,3,3,1
|
||||||
|
11,80,0,63,76,1,0,0,2,1
|
||||||
|
12,95,0,75,32,1,1,1,1,1
|
||||||
|
13,76,0,30,43,2,1,2,0,1
|
||||||
|
14,2,0,92,9,2,1,3,0,1
|
||||||
|
1,6,0,5,10,4,3,1,3,0
|
||||||
|
2,7,0,4,20,4,3,2,2,0
|
||||||
|
3,4,0,11,30,4,3,3,1,0
|
||||||
|
4,5,0,43,5,2,3,1,2,0
|
||||||
|
5,6,0,9,17,2,3,2,1,0
|
||||||
|
6,2,0,98,18,4,3,3,1,0
|
||||||
|
7,11,0,54,19,4,3,0,2,0
|
||||||
|
8,20,0,43,22,4,3,1,1,0
|
||||||
|
9,30,0,65,43,4,3,2,3,0
|
||||||
|
10,60,0,87,50,1,3,3,3,0
|
||||||
|
11,80,0,63,76,1,3,0,2,0
|
||||||
|
12,95,0,75,32,1,3,1,1,0
|
||||||
|
13,76,0,30,43,2,3,2,0,0
|
||||||
|
14,2,0,92,9,2,3,3,0,0
|
|
@ -9,20 +9,21 @@ class Drzewo:
|
|||||||
|
|
||||||
def treeLearn(self):
|
def treeLearn(self):
|
||||||
csvdata=pandas.read_csv('Data/dataTree.csv')
|
csvdata=pandas.read_csv('Data/dataTree.csv')
|
||||||
|
#csvdata = pandas.read_csv('Data/dataTree2.csv')
|
||||||
x=csvdata[atributes]
|
x=csvdata[atributes]
|
||||||
decision=csvdata['action']
|
decision=csvdata['action']
|
||||||
self.tree=skltree.DecisionTreeClassifier()
|
self.tree=skltree.DecisionTreeClassifier()
|
||||||
self.tree=self.tree.fit(x.values,decision)
|
self.tree=self.tree.fit(x.values,decision)
|
||||||
|
|
||||||
def plotTree(self):
|
def plotTree(self):
|
||||||
plt.figure()
|
plt.figure(figsize=(20,30))
|
||||||
skltree.plot_tree(self.tree,filled=True,feature_names=atributes)
|
skltree.plot_tree(self.tree,filled=True,feature_names=atributes)
|
||||||
plt.title("Drzewo decyzyjne wytrenowane na przygotowanych danych")
|
plt.title("Drzewo decyzyjne wytrenowane na przygotowanych danych")
|
||||||
plt.savefig('tree.png')
|
plt.savefig('tree.png')
|
||||||
plt.show()
|
#plt.show()
|
||||||
def makeDecision(self,values):
|
def makeDecision(self,values):
|
||||||
action=self.tree.predict([values]) #0- nie podlewac, 1-podlewac
|
action=self.tree.predict([values]) #0- nie podlewac, 1-podlewac
|
||||||
if(action==[0]):
|
if(action==[0]):
|
||||||
return "Nie podlewac"
|
return "Nie"
|
||||||
if(action==[1]):
|
if(action==[1]):
|
||||||
return "Podlewac"
|
return "Tak"
|
@ -118,3 +118,6 @@ class Roslina:
|
|||||||
|
|
||||||
def report_status(self):
|
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()
|
8
Slot.py
8
Slot.py
@ -22,8 +22,12 @@ class Slot:
|
|||||||
pygame.draw.rect(self.screen,Colors.BLACK,self.field,BORDER_THICKNESS) #Draw border
|
pygame.draw.rect(self.screen,Colors.BLACK,self.field,BORDER_THICKNESS) #Draw border
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
def redraw_image(self):
|
def redraw_image(self, destroy = True):
|
||||||
self.mark_visited()
|
if destroy:
|
||||||
|
self.mark_visited()
|
||||||
|
else:
|
||||||
|
self.screen.blit(self.plant_image, (self.x_axis * dCon.CUBE_SIZE, self.y_axis * dCon.CUBE_SIZE))
|
||||||
|
pygame.draw.rect(self.screen, Colors.BLACK, self.field, BORDER_THICKNESS)
|
||||||
|
|
||||||
def mark_visited(self):
|
def mark_visited(self):
|
||||||
plant,self.plant_image=self.image_loader.return_plant('road')
|
plant,self.plant_image=self.image_loader.return_plant('road')
|
||||||
|
1
Stan.py
1
Stan.py
@ -63,3 +63,4 @@ class Stan:
|
|||||||
|
|
||||||
def report_all(self):
|
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()}"
|
||||||
|
|
||||||
|
60
Tractor.py
60
Tractor.py
@ -13,6 +13,8 @@ import Drzewo
|
|||||||
condition=Condition.Condition()
|
condition=Condition.Condition()
|
||||||
drzewo=Drzewo.Drzewo()
|
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,
|
tab = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
||||||
1, 1, 1, 1, 1, 0, 1, 0, 1, 1,
|
1, 1, 1, 1, 1, 0, 1, 0, 1, 1,
|
||||||
@ -63,17 +65,24 @@ class Tractor:
|
|||||||
self.current_tractor_image = self.tractor_images[self.direction]
|
self.current_tractor_image = self.tractor_images[self.direction]
|
||||||
self.draw_tractor()
|
self.draw_tractor()
|
||||||
|
|
||||||
def tree_move(self):
|
def tree_move(self, pole):
|
||||||
drzewo.treeLearn()
|
drzewo.treeLearn()
|
||||||
drzewo.plotTree()
|
drzewo.plotTree()
|
||||||
|
self.snake_move_irrigation(pole, drzewo)
|
||||||
|
|
||||||
|
def get_attributes(self):
|
||||||
slot_attributes=self.slot.return_stan_for_tree()
|
slot_attributes=self.slot.return_stan_for_tree()
|
||||||
climate_attributes=condition.return_condition()
|
climate_attributes=condition.return_condition()
|
||||||
attributes=[]
|
attributes=[]
|
||||||
attributes=attributes+slot_attributes+[self.waterLevel]+climate_attributes
|
attributes=attributes+slot_attributes+[self.waterLevel]+climate_attributes
|
||||||
print("Decyzja czy podlac:",drzewo.makeDecision(attributes),"Atrybuty tego stanu to:",attributes)
|
return attributes
|
||||||
#TODO SNAKE MOVE AND USING drzewo.makeDecision(attributes)for each slot. Also we need to cycle climate for each slot change
|
|
||||||
#condition.cycle()
|
def get_attributes_for_print(self):
|
||||||
#condition.getCondition()
|
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):
|
def turn_right(self):
|
||||||
# zmiana kierunku w prawo
|
# zmiana kierunku w prawo
|
||||||
direction_map = {
|
direction_map = {
|
||||||
@ -86,7 +95,7 @@ class Tractor:
|
|||||||
self.current_tractor_image = self.tractor_images[self.direction]
|
self.current_tractor_image = self.tractor_images[self.direction]
|
||||||
self.draw_tractor()
|
self.draw_tractor()
|
||||||
|
|
||||||
def move_forward(self, pole):
|
def move_forward(self, pole, destroy = True):
|
||||||
next_slot_coordinates = None
|
next_slot_coordinates = None
|
||||||
if self.direction == Tractor.DIRECTION_EAST:
|
if self.direction == Tractor.DIRECTION_EAST:
|
||||||
next_slot_coordinates = (self.slot.x_axis + 1, self.slot.y_axis)
|
next_slot_coordinates = (self.slot.x_axis + 1, self.slot.y_axis)
|
||||||
@ -102,12 +111,13 @@ class Tractor:
|
|||||||
self.current_tractor_image = self.tractor_images[self.direction]
|
self.current_tractor_image = self.tractor_images[self.direction]
|
||||||
|
|
||||||
# sprawdzenie czy następny slot jest dobry
|
# sprawdzenie czy następny slot jest dobry
|
||||||
self.do_move_if_valid(pole,next_slot_coordinates)
|
self.do_move_if_valid(pole,next_slot_coordinates, destroy)
|
||||||
|
self.clock.tick(10)
|
||||||
|
|
||||||
def do_move_if_valid(self,pole, next_slot_coordinates):
|
def do_move_if_valid(self,pole, next_slot_coordinates, destroy = True):
|
||||||
if next_slot_coordinates and pole.is_valid_move(next_slot_coordinates):
|
if next_slot_coordinates and pole.is_valid_move(next_slot_coordinates):
|
||||||
next_slot = pole.get_slot_from_cord(next_slot_coordinates)
|
next_slot = pole.get_slot_from_cord(next_slot_coordinates)
|
||||||
self.slot.redraw_image()
|
self.slot.redraw_image(destroy)
|
||||||
self.slot = next_slot
|
self.slot = next_slot
|
||||||
self.draw_tractor()
|
self.draw_tractor()
|
||||||
return True
|
return True
|
||||||
@ -153,6 +163,34 @@ class Tractor:
|
|||||||
self.snake_move(pole,x,y)
|
self.snake_move(pole,x,y)
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
attributes=self.get_attributes()
|
||||||
|
decision = drzewo.makeDecision(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 == "Tak":
|
||||||
|
self.slot.irrigatePlant()
|
||||||
|
counter += 1
|
||||||
|
condition.cycle()
|
||||||
|
pygame.time.delay(50)
|
||||||
|
self.waterLevel=random.randint(0,100)
|
||||||
|
#condition.getCondition()
|
||||||
|
self.move_forward(pole, False)
|
||||||
|
if i % 2 == 0 and i != dCon.NUM_Y - 1:
|
||||||
|
self.turn_right()
|
||||||
|
self.move_forward(pole, False)
|
||||||
|
self.turn_right()
|
||||||
|
elif i != dCon.NUM_Y - 1:
|
||||||
|
self.turn_left()
|
||||||
|
self.move_forward(pole, False)
|
||||||
|
self.turn_left()
|
||||||
|
print("podlanych slotów: ", str(counter))
|
||||||
|
|
||||||
def snake_move(self,pole,x,y):
|
def snake_move(self,pole,x,y):
|
||||||
next_slot_coordinates=(x,y)
|
next_slot_coordinates=(x,y)
|
||||||
if(self.do_move_if_valid(pole,next_slot_coordinates)):
|
if(self.do_move_if_valid(pole,next_slot_coordinates)):
|
||||||
@ -197,9 +235,11 @@ class Tractor:
|
|||||||
print("- Typ:", akcja.typ)
|
print("- Typ:", akcja.typ)
|
||||||
else:
|
else:
|
||||||
print("Brak akcji przypisanych do tego sprzętu.")
|
print("Brak akcji przypisanych do tego sprzętu.")
|
||||||
|
|
||||||
|
def pretty_print_tree(self,attributes):
|
||||||
|
print(format_string.format(*attributes))
|
||||||
def irrigateSlot(self):
|
def irrigateSlot(self):
|
||||||
try:
|
try:
|
||||||
self.slot.irrigatePlant()
|
self.slot.irrigatePlant()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user