refactor #26

Merged
s481834 merged 34 commits from refactor into master 2024-06-04 13:25:11 +02:00
24 changed files with 10011 additions and 35 deletions

5
.gitignore vendored
View File

@ -1,2 +1,5 @@
__pycache__/
.idea/
.idea/
tree.png
dataset/
dataset.zip

36
App.py

File diff suppressed because one or more lines are too long

49
Climate.py Normal file
View File

@ -0,0 +1,49 @@
#THESE DICTIONARIES ARE USED FOR DISPLAY AND FOR DOCUMENTATION PURPOSES
seasons={
0:"zima",
1:"wiosna",
2:"lato",
3:"jesien"}
time={
0:"rano",
1:"poludnie",
2:"wieczor",
3:"noc"}
rain={
0:"brak",
1:"lekki deszcz",
2:"normalny deszcz",
3:"ulewa"
}
temperature={
0:"bardzo zimno",
1:"zimno",
2:"przecietnie",
3:"cieplo",
4:"upal",}
def getNextSeason(season):
if(season==3):
return 0
else:
return season+1
def getNextTime(currentTime):
if(currentTime==3):
return 0
else:
return currentTime+1
def getAmount(type):
if(type=="seasons"):
return len(seasons)
if(type=="rain"):
return len(rain)
if(type=="time"):
return len(time)
if(type=="temperature"):
return len(temperature)

47
Condition.py Normal file
View File

@ -0,0 +1,47 @@
import random
import Climate
import Ui
class Condition:
def __init__(self):
self.season=self.setRandomSeason()
self.currentTime=self.setRandomTime()
self.rain=self.setRandomRain()
self.temperature=self.setRandomRain()
self.clock=0
def setRandomSeason(self):
return self.randomizer(Climate.getAmount("seasons"))
def setRandomTime(self):
return self.randomizer(Climate.getAmount("time"))
def setRandomRain(self):
return self.randomizer(Climate.getAmount("rain"))
def setRandomTemperature(self):
return self.randomizer(Climate.getAmount("temperature"))
def randomizer(self,max):
return random.randint(0,max-1)
def cycle(self):
if(self.clock==11):
self.currentTime=0
self.rain=self.setRandomRain()
self.temperature=self.setRandomTemperature()
self.season=Climate.getNextSeason(self.season)
self.clock=0
return
else:
self.currentTime=Climate.getNextTime(self.currentTime)
self.rain=self.setRandomRain()
self.temperature=self.setRandomTemperature()
self.clock=self.clock+1
def return_condition(self):
return [self.temperature,self.rain,self.season,self.currentTime]
def getCondition(self):
return ([Climate.temperature[self.temperature],Climate.rain[self.rain],Climate.seasons[self.season],Climate.time[self.currentTime]])

9219
Data/dataTree.csv Normal file

File diff suppressed because it is too large Load Diff

248
Data/dataTree2.csv Normal file
View 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
1 plant_water_level growth disease fertility tractor_water_level temperature rain season current_time action
2 1 20 0 40 60 2 0 2 1 1
3 20 40 0 40 60 2 0 2 1 1
4 87 20 0 40 60 2 0 2 1 0
5 27 43 1 40 60 2 0 2 1 0
6 89 56 1 40 60 2 1 1 1 0
7 67 100 1 37 55 1 3 3 3 0
8 67 40 1 87 90 4 0 1 0 0
9 1 20 0 40 60 2 0 0 1 0
10 20 40 0 40 60 2 0 0 1 0
11 87 20 0 56 45 2 0 0 2 0
12 27 43 1 40 60 2 0 0 3 0
13 89 56 1 40 89 2 1 0 1 0
14 67 100 1 37 55 1 3 0 3 0
15 67 40 1 87 90 4 0 0 0 0
16 1 100 0 45 20 2 0 2 1 0
17 20 100 0 40 34 0 1 2 0 0
18 87 100 0 56 60 2 0 1 1 0
19 27 100 0 89 67 1 2 2 2 0
20 89 100 0 40 60 2 1 1 1 0
21 76 100 0 37 55 1 3 3 3 0
22 67 100 0 87 90 4 0 1 0 0
23 1 20 0 40 0 2 0 2 1 0
24 20 40 0 40 0 2 0 2 1 0
25 87 20 0 40 0 2 0 2 1 0
26 27 43 1 40 0 2 0 2 1 0
27 89 56 1 40 0 2 1 1 1 0
28 67 100 1 37 0 1 3 3 3 0
29 67 40 1 87 0 4 0 1 0 0
30 1 20 0 40 0 2 0 0 1 0
31 20 40 0 40 0 2 0 0 1 0
32 87 20 0 56 0 2 0 0 2 0
33 27 43 1 40 0 2 0 0 3 0
34 89 56 1 40 0 2 1 0 1 0
35 67 100 1 37 0 1 3 0 3 0
36 67 40 1 87 0 4 0 0 0 0
37 1 100 0 45 0 2 0 2 1 0
38 20 100 0 40 0 0 1 2 0 0
39 87 100 0 56 0 2 0 1 1 0
40 27 100 0 89 0 1 2 2 2 0
41 89 100 0 40 0 2 1 1 1 0
42 76 100 0 37 0 1 3 3 3 0
43 67 100 0 87 0 4 0 1 0 0
44 1 45 0 56 44 2 1 1 1 1
45 20 55 0 43 34 2 0 2 2 1
46 15 23 0 23 26 2 1 3 3 1
47 45 67 0 12 67 3 0 1 0 1
48 59 88 0 34 87 3 0 2 1 1
49 32 32 0 32 90 3 0 3 2 1
50 44 43 0 19 27 2 0 1 3 1
51 33 11 0 28 76 2 0 2 0 1
52 54 90 0 44 5 3 0 3 1 1
53 21 76 0 50 25 3 1 1 2 1
54 29 64 0 38 36 2 0 2 3 1
55 11 54 0 65 44 3 1 1 2 1
56 23 55 0 34 43 3 0 2 1 1
57 51 32 0 32 62 3 1 3 3 1
58 54 76 0 21 76 2 0 1 2 1
59 95 88 0 43 78 2 0 2 1 0
60 23 23 0 23 9 2 0 3 3 1
61 44 34 0 91 72 3 0 1 0 1
62 33 11 0 82 67 3 0 2 2 1
63 45 9 0 44 50 2 0 3 3 1
64 21 67 0 50 52 2 1 1 0 1
65 92 46 0 83 63 3 0 2 1 0
66 20 55 1 43 34 0 0 2 2 0
67 15 23 1 23 26 0 1 3 3 0
68 45 67 1 12 67 0 0 1 0 0
69 59 88 1 34 87 0 0 2 1 0
70 32 32 0 32 90 0 0 3 2 0
71 44 43 0 19 27 4 0 1 3 0
72 33 11 0 28 76 4 0 2 0 0
73 54 90 0 44 5 4 0 3 1 0
74 21 76 0 50 25 4 1 1 2 0
75 29 64 0 38 36 4 0 2 3 0
76 11 54 0 65 44 0 1 1 2 0
77 23 55 0 34 43 0 0 2 1 0
78 51 32 0 32 62 0 1 3 3 0
79 80 76 1 39 7 3 0 1 0 0
80 98 77 0 15 91 1 3 2 3 0
81 3 48 1 73 41 2 2 0 3 0
82 20 15 1 97 87 4 1 2 1 0
83 93 6 0 37 0 0 1 0 1 0
84 4 31 0 1 5 2 3 1 2 0
85 42 52 0 33 19 3 2 3 0 0
86 76 43 0 77 18 4 0 0 3 0
87 31 13 1 21 42 0 1 2 3 0
88 96 65 1 63 35 1 3 3 2 0
89 29 39 0 40 37 3 3 0 0 0
90 82 53 0 55 9 0 1 3 2 0
91 21 35 0 58 1 1 2 2 0 0
92 92 98 0 69 16 3 0 0 1 0
93 34 23 0 95 2 2 3 0 3 0
94 36 28 0 62 22 0 1 1 1 0
95 66 88 1 10 85 3 1 2 3 0
96 53 51 0 79 90 2 2 3 2 0
97 9 74 0 60 4 4 1 2 3 1
98 17 0 0 38 58 1 2 3 0 0
99 12 76 0 50 25 3 1 1 2 1
100 92 64 0 38 36 2 0 2 3 0
101 11 54 0 65 44 3 1 1 2 1
102 32 55 0 34 43 3 0 2 1 1
103 15 32 0 32 62 3 1 3 3 1
104 45 76 0 21 76 2 0 1 2 1
105 59 88 0 43 78 2 0 2 1 1
106 32 23 0 23 9 2 0 3 3 1
107 14 34 0 91 72 3 0 1 0 1
108 13 11 0 82 67 3 0 2 2 1
109 45 9 0 44 50 2 0 3 3 1
110 21 67 0 50 52 2 1 1 0 1
111 92 46 0 83 63 3 0 2 1 0
112 2 40 1 34 43 1 3 2 2 0
113 51 32 1 32 62 2 1 3 3 0
114 54 76 1 21 76 3 0 1 0 0
115 98 38 0 50 44 4 0 1 0 0
116 63 7 0 93 79 2 0 2 1 1
117 91 59 0 94 24 4 0 3 2 0
118 11 49 0 54 76 2 0 1 3 1
119 33 31 0 59 39 3 0 1 3 1
120 28 50 0 26 0 4 0 2 2 0
121 54 83 0 36 0 3 0 2 1 0
122 49 78 0 68 0 2 0 3 2 0
123 59 21 0 43 100 1 0 3 2 1
124 1 30 0 52 100 2 0 0 3 0
125 60 9 0 40 40 3 0 0 3 0
126 85 94 0 87 85 4 0 1 3 0
127 79 68 0 56 90 1 0 2 2 1
128 75 22 0 25 95 1 0 3 2 1
129 100 51 0 33 12 0 0 2 2 0
130 90 70 0 71 81 0 0 2 1 0
131 47 26 0 6 78 4 0 1 1 1
132 14 89 0 70 18 4 0 1 0 1
133 99 19 0 74 91 2 0 3 0 0
134 18 48 0 15 32 2 0 3 0 1
135 5 57 0 14 34 0 1 1 3 1
136 22 67 0 9 5 0 1 2 2 0
137 95 81 0 46 86 1 1 3 1 0
138 39 65 0 84 0 1 1 0 0 0
139 84 75 0 30 0 2 1 1 1 0
140 86 41 0 2 67 2 1 2 2 0
141 64 53 0 53 47 1 1 3 3 1
142 69 61 0 0 73 2 1 0 0 0
143 94 40 1 0 18 3 1 1 2 0
144 62 82 1 20 50 4 1 2 3 0
145 57 1 1 17 92 0 1 3 2 0
146 80 35 1 58 45 0 0 3 1 0
147 30 47 1 8 47 1 0 2 1 0
148 82 32 0 99 39 1 3 1 3 0
149 20 84 0 0 51 2 3 2 3 0
150 42 88 0 0 54 2 2 2 0 0
151 66 45 0 91 10 3 2 1 0 0
152 81 14 0 19 55 3 0 1 2 1
153 74 37 0 88 78 4 0 3 2 1
154 89 99 0 100 60 4 0 3 3 0
155 15 20 0 45 11 0 0 1 3 1
156 92 28 0 85 90 2 0 1 1 0
157 55 4 0 13 95 2 0 2 1 1
158 2 6 0 35 0 2 0 2 0 0
159 61 56 0 90 0 2 0 3 0 0
160 76 11 0 61 10 3 0 3 1 1
161 26 80 0 57 9 3 0 1 2 1
162 40 44 0 81 8 3 0 2 3 1
163 50 66 0 23 7 3 0 3 0 1
164 48 15 0 77 6 2 0 0 1 0
165 11 54 0 65 44 3 3 1 2 0
166 23 55 0 34 43 3 3 2 1 0
167 51 32 0 32 62 3 3 3 3 0
168 54 76 0 21 76 2 3 1 2 0
169 95 88 0 43 78 2 3 2 1 0
170 23 23 0 23 9 2 3 3 3 0
171 44 34 0 91 72 3 3 1 0 0
172 33 11 0 82 67 3 3 2 2 0
173 45 9 0 44 50 2 3 3 3 0
174 21 67 0 50 52 2 3 1 0 0
175 92 46 0 83 63 3 3 2 1 0
176 20 55 1 43 34 0 3 2 2 0
177 15 23 1 23 26 0 3 3 3 0
178 45 67 1 12 67 0 3 1 0 0
179 59 88 1 34 87 0 3 2 1 0
180 32 32 0 32 90 0 3 3 2 0
181 1 60 0 55 11 0 1 0 0 1
182 2 70 0 44 12 1 1 0 1 1
183 3 44 0 11 13 2 1 0 2 1
184 4 55 0 34 66 3 0 0 3 1
185 5 66 0 90 77 0 0 1 2 1
186 6 22 0 89 88 0 0 2 2 1
187 7 1 0 45 9 0 1 2 3 1
188 8 2 0 34 22 3 1 2 3 1
189 9 3 0 56 34 3 1 0 1 1
190 10 6 0 78 5 3 0 3 1 1
191 11 8 0 36 67 2 0 0 0 1
192 12 59 0 57 23 2 1 1 0 1
193 13 67 0 29 34 1 1 0 1 1
194 14 20 0 30 90 1 1 2 2 1
195 15 21 0 66 89 0 1 3 3 1
196 44 100 0 91 72 3 3 1 0 0
197 33 100 0 82 67 3 3 2 2 0
198 45 100 0 44 50 2 3 3 3 0
199 21 100 0 50 52 2 3 1 0 0
200 92 100 0 83 63 3 3 2 1 0
201 20 100 1 43 34 0 3 2 2 0
202 15 100 1 23 26 0 3 3 3 0
203 45 100 1 12 67 0 3 1 0 0
204 59 100 1 34 87 0 3 2 1 0
205 32 100 0 32 90 0 3 3 2 0
206 1 100 0 55 11 0 1 0 0 0
207 2 100 0 44 12 1 1 0 1 0
208 3 100 0 11 13 2 1 0 2 0
209 4 100 0 34 66 3 0 0 3 0
210 5 100 0 90 77 0 0 1 2 0
211 6 100 0 89 88 0 0 2 2 0
212 7 100 0 45 9 0 1 2 3 0
213 8 100 0 34 22 3 1 2 3 0
214 9 100 0 56 34 3 1 0 1 0
215 10 100 0 78 5 3 0 3 1 0
216 11 100 0 36 67 2 0 0 0 0
217 12 100 0 57 23 2 1 1 0 0
218 13 100 0 29 34 1 1 0 1 0
219 14 100 0 30 90 1 1 2 2 0
220 15 100 0 66 89 0 1 3 3 0
221 1 6 0 5 10 4 1 1 3 1
222 2 7 0 4 20 4 1 2 2 1
223 3 4 0 11 30 4 1 3 1 1
224 4 5 0 43 5 2 0 1 2 1
225 5 6 0 9 17 2 0 2 1 1
226 6 2 0 98 18 4 0 3 1 1
227 7 11 0 54 19 4 1 0 2 1
228 8 20 0 43 22 4 1 1 1 1
229 9 30 0 65 43 4 1 2 3 1
230 10 60 0 87 50 1 0 3 3 1
231 11 80 0 63 76 1 0 0 2 1
232 12 95 0 75 32 1 1 1 1 1
233 13 76 0 30 43 2 1 2 0 1
234 14 2 0 92 9 2 1 3 0 1
235 1 6 0 5 10 4 3 1 3 0
236 2 7 0 4 20 4 3 2 2 0
237 3 4 0 11 30 4 3 3 1 0
238 4 5 0 43 5 2 3 1 2 0
239 5 6 0 9 17 2 3 2 1 0
240 6 2 0 98 18 4 3 3 1 0
241 7 11 0 54 19 4 3 0 2 0
242 8 20 0 43 22 4 3 1 1 0
243 9 30 0 65 43 4 3 2 3 0
244 10 60 0 87 50 1 3 3 3 0
245 11 80 0 63 76 1 3 0 2 0
246 12 95 0 75 32 1 3 1 1 0
247 13 76 0 30 43 2 3 2 0 0
248 14 2 0 92 9 2 3 3 0 0

29
Drzewo.py Normal file
View File

@ -0,0 +1,29 @@
from sklearn import tree as skltree
import pandas,os
import matplotlib.pyplot as plt
atributes=['plant_water_level','growth','disease','fertility','tractor_water_level','temperature','rain','season','current_time'] #Columns in CSV file has to be in the same order
class Drzewo:
def __init__(self):
self.tree=self.treeLearn()
def treeLearn(self):
csvdata=pandas.read_csv('Data/dataTree.csv')
#csvdata = pandas.read_csv('Data/dataTree2.csv')
x=csvdata[atributes]
decision=csvdata['action']
self.tree=skltree.DecisionTreeClassifier()
self.tree=self.tree.fit(x.values,decision)
def plotTree(self):
plt.figure(figsize=(20,30))
skltree.plot_tree(self.tree,filled=True,feature_names=atributes)
plt.title("Drzewo decyzyjne wytrenowane na przygotowanych danych: ")
plt.savefig('tree.png')
#plt.show()
def makeDecision(self,values):
action=self.tree.predict([values]) #0- nie podlewac, 1-podlewac
if(action==[0]):
return "Nie"
if(action==[1]):
return "Tak"

View File

@ -1,6 +1,8 @@
import pygame
import displayControler as dCon
import random
import neuralnetwork
import os
class Image:
def __init__(self):
@ -37,7 +39,7 @@ class Image:
self.gasStation_image=pygame.transform.scale(gasStation,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
def return_random_plant(self):
x=random.randint(0,7)
x=random.randint(0,5) #disabled dirt and mud generation
keys=list(self.plants_image_dict.keys())
plant=keys[x]
return (plant,self.plants_image_dict[plant])
@ -53,3 +55,28 @@ class Image:
def return_gasStation(self):
return self.gasStation_image
# losowanie zdjęcia z testowego datasetu bez powtórzeń
imagePathList = []
def getRandomImageFromDataBase():
label = random.choice(neuralnetwork.labels)
folderPath = f"dataset/test/{label}"
files = os.listdir(folderPath)
random_image = random.choice(files)
imgPath = os.path.join(folderPath, random_image)
while imgPath in imagePathList:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
label = random.choice(neuralnetwork.labels)
folderPath = f"dataset/test/{label}"
files = os.listdir(folderPath)
random_image = random.choice(files)
imgPath = os.path.join(folderPath, random_image)
imagePathList.append(imgPath)
image = pygame.image.load(imgPath)
image=pygame.transform.scale(image,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
return image, label, imgPath

19
Pole.py
View File

@ -6,6 +6,8 @@ import time
import Ui
import math
import random
import neuralnetwork
import Image
stoneList = [(3,3), (3,4), (3,5), (3,6), (4,6), (5,6), (6,6), (7,6), (8,6), (9,6), (10,6), (11,6), (12,6), (13,6), (14,6), (15,6), (16,6), (16,7), (16,8), (16,9)]
stoneFlag = False
@ -30,7 +32,7 @@ class Pole:
return self.slot_dict
#Draw grid and tractor (new one)
def draw_grid(self):
def draw_grid(self, nn=False):
for x in range(0,dCon.NUM_X): #Draw all cubes in X axis
for y in range(0,dCon.NUM_Y): #Draw all cubes in Y axis
new_slot=Slot.Slot(x,y,Colors.BROWN,self.screen,self.image_loader) #Creation of empty slot
@ -44,19 +46,22 @@ class Pole:
for i in stoneList:
st=self.slot_dict[i]
st.set_stone_image()
if self.gasStation[0] != -1:
st=self.slot_dict[self.gasStation]
st.set_gasStation_image()
if self.gasStation[0] != -1:
st=self.slot_dict[self.gasStation]
st.set_gasStation_image()
def randomize_colors(self):
def randomize_colors(self, nn = False):
pygame.display.update()
time.sleep(3)
#self.ui.render_text("Randomizing Crops")
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
else:
self.slot_dict[coordinates].set_random_plant()
self.slot_dict[coordinates].set_random_plant(nn)
def change_color_of_slot(self,coordinates,color): #Coordinates must be tuple (x,y) (left top slot has cord (0,0) ), color has to be from defined in Colors.py or custom in RGB value (R,G,B)
self.get_slot_from_cord(coordinates).color_change(color)

View File

@ -110,8 +110,14 @@ class Roslina:
def return_stan(self):
return self.stan
def return_stan_for_tree(self):
return self.stan.return_stan_for_tree()
def get_hydrate_stats(self):
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()

27
Slot.py
View File

@ -16,14 +16,20 @@ class Slot:
self.field=pygame.Rect(self.x_axis*dCon.CUBE_SIZE,self.y_axis*dCon.CUBE_SIZE,dCon.CUBE_SIZE,dCon.CUBE_SIZE)
self.image_loader=image_loader
self.garage_image=None
self.label = None
self.imagePath = None
def draw(self):
pygame.draw.rect(self.screen,Colors.BROWN,self.field,0) #Draw field
pygame.draw.rect(self.screen,Colors.BLACK,self.field,BORDER_THICKNESS) #Draw border
pygame.display.update()
def redraw_image(self):
self.mark_visited()
def redraw_image(self, destroy = True):
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):
plant,self.plant_image=self.image_loader.return_plant('road')
@ -34,9 +40,14 @@ class Slot:
self.plant=color
self.draw()
def set_random_plant(self):
(plant_name,self.plant_image)=self.random_plant()
self.plant=Roslina.Roslina(plant_name)
def set_random_plant(self, nn=False):
if not nn:
(plant_name,self.plant_image)=self.random_plant()
self.plant=Roslina.Roslina(plant_name)
else:
self.plant_image, self.label, self.imagePath = self.random_plant_dataset()
# print(self.plant_image)
self.plant=Roslina.Roslina(self.label)
self.set_image()
def set_image(self):
@ -62,6 +73,8 @@ class Slot:
def random_plant(self): #Probably will not be used later only for demo purpouse
return self.image_loader.return_random_plant()
def random_plant_dataset(self):
return Image.getRandomImageFromDataBase()
def return_plant(self):
return self.plant
@ -82,4 +95,6 @@ class Slot:
self.plant.stan.nawodnienie=random.randint(61,100)
elif(index==-1):
pass
def return_stan_for_tree(self):
return self.plant.return_stan_for_tree()

20
Stan.py
View File

@ -5,7 +5,7 @@ class Stan:
nawodnienie = None #[int] 0-100 (0-60: trzeba podlać), spada w zaleznosci od rosliny: aktualizowane bedzie "w tle"
zyznosc = None #[int] 0-100 (0-60: trzeba użyźnić), spada w zaleznosci od rosliny: aktualizowane bedzie "w tle"
wzrost = None #[int] 0-100 (75-100: scinanie), wzrasta w zaleznosci od rosliny: aktualizowane bedzie "w tle"
choroba = None #[string] brak, grzyb, bakteria, pasożyt
choroba = None #[int] brak-0,choroba-1
akcja = None #[Akcja]
koszt = None #[int] 0-15, im więcej tym trudniej wjechać
@ -24,7 +24,7 @@ class Stan:
self.nawodnienie=random.randint(0,100)
self.zyznosc=random.randint(0,100)
self.wzrost=random.randint(0,100)
self.choroba=random.choice(["brak","grzyb","bakteria","pasozyt"])
self.choroba=random.randint(0,1)
def checkStan(self):
# sprawdza stan rośliny i podejmuje akcje jeśli potrzebna
@ -47,6 +47,20 @@ class Stan:
def return_hydrate(self):
return self.nawodnienie
def return_disease(self):
return self.choroba
def return_disease_as_string(self):
if(self.choroba==0):
return "Zdrowa"
if(self.choroba==1):
return "Chora"
def return_stan_for_tree(self):
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.choroba} Koszt wejścia: {self.koszt}"
return f"Nawodnienie: {self.nawodnienie} Zyznosc: {self.zyznosc} Wzrost: {self.wzrost} Choroba: {self.return_disease_as_string()}"

View File

@ -7,6 +7,16 @@ import displayControler as dCon
import Slot
import Osprzet
import Node
import Condition
import Drzewo
import neuralnetwork as nn
condition=Condition.Condition()
drzewo=Drzewo.Drzewo()
format_string = "{:<25}{:<25}{:<25}{:<10}{:<10}{:<10}{:<25}{:<15}{:<20}{:<10}{:<15}"
format_string_nn="{:<10}{:<20}{:<20}{:<15}{:<20}"
tab = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 1, 0, 1, 1,
@ -39,7 +49,7 @@ class Tractor:
self.clock=clock
self.slot_hydrate_dict={}
self.bfs2_flag=bfs2_flag
self.waterLevel=random.randint(0,100)
def draw_tractor(self):
self.screen.blit(self.current_tractor_image, (self.slot.x_axis * dCon.CUBE_SIZE, self.slot.y_axis * dCon.CUBE_SIZE))
@ -57,6 +67,24 @@ class Tractor:
self.current_tractor_image = self.tractor_images[self.direction]
self.draw_tractor()
def tree_move(self, pole):
drzewo.treeLearn()
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
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 = {
@ -69,7 +97,7 @@ class Tractor:
self.current_tractor_image = self.tractor_images[self.direction]
self.draw_tractor()
def move_forward(self, pole):
def move_forward(self, pole, destroy = True):
next_slot_coordinates = None
if self.direction == Tractor.DIRECTION_EAST:
next_slot_coordinates = (self.slot.x_axis + 1, self.slot.y_axis)
@ -85,12 +113,13 @@ class Tractor:
self.current_tractor_image = self.tractor_images[self.direction]
# 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):
next_slot = pole.get_slot_from_cord(next_slot_coordinates)
self.slot.redraw_image()
self.slot.redraw_image(destroy)
self.slot = next_slot
self.draw_tractor()
return True
@ -136,6 +165,63 @@ class Tractor:
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_predict_plant(self, pole, model):
headers=['Coords','Real plant','Predicted plant','Result','Fertilizer']
print(format_string_nn.format(*headers))
initPos = (self.slot.x_axis, self.slot.y_axis)
count = 0
for i in range(initPos[1], dCon.NUM_Y):
for j in range(initPos[0], dCon.NUM_X):
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
if self.slot.imagePath != None:
predictedLabel = nn.predictLabel(self.slot.imagePath, model)
#print(str("Coords: ({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis), "real:", self.slot.label, "predicted:", predictedLabel, "correct" if (self.slot.label == predictedLabel) else "incorrect", 'nawożę za pomocą:', nn.fertilizer[predictedLabel])
print(format_string_nn.format(f"{self.slot.x_axis,self.slot.y_axis}",self.slot.label,predictedLabel,"correct" if (self.slot.label == predictedLabel) else "incorrect",nn.fertilizer[predictedLabel]))
if self.slot.label != predictedLabel:
self.slot.mark_visited()
count += 1
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(f"Dobrze nawiezionych roślin: {20*12-count}, źle nawiezionych roślin: {count}")
def snake_move(self,pole,x,y):
next_slot_coordinates=(x,y)
if(self.do_move_if_valid(pole,next_slot_coordinates)):
@ -180,9 +266,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

View File

@ -1,3 +1,3 @@
import App
App.init(demo=True)#DEMO=TRUE WILL INIT DEMO MODE WITH RANDOM COLOR GEN
App.init(demo=True)#DEMO=TRUE WILL INIT DEMO MODE WITH RANDOM COLOR GEN

BIN
model_2_crops.pth Normal file

Binary file not shown.

BIN
model_500_hidden.pth Normal file

Binary file not shown.

114
neuralnetwork.py Normal file
View File

@ -0,0 +1,114 @@
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision.transforms import Compose, Lambda, ToTensor
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
from PIL import Image
import random
imageSize = (128, 128)
labels = ['carrot','corn', 'potato', 'tomato'] # musi być w kolejności alfabetycznej
fertilizer = {labels[0]: 'kompost', labels[1]: 'saletra amonowa', labels[2]: 'superfosfat', labels[3]:'obornik kurzy'}
#labels = ['corn','tomato'] #uncomment this two lines for 2 crops only
#fertilizer = {labels[0]: 'kompost', labels[1]: 'saletra amonowa'}
torch.manual_seed(42)
#device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device = torch.device("cpu")
# device = torch.device("mps") if torch.backends.mps.is_available() else torch.device('cpu')
# print(device)
def getTransformation():
transform=transforms.Compose([
transforms.ToTensor(),
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
transforms.Resize(imageSize),
Lambda(lambda x: x.flatten())])
return transform
def getDataset(train=True):
transform = getTransformation()
if (train):
trainset = datasets.ImageFolder(root='dataset/train', transform=transform)
return trainset
else:
testset = datasets.ImageFolder(root='dataset/test', transform=transform)
return testset
def train(model, dataset, n_iter=100, batch_size=256):
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
criterion = nn.NLLLoss()
dl = DataLoader(dataset, batch_size=batch_size)
model.train()
for epoch in range(n_iter):
for images, targets in dl:
optimizer.zero_grad()
out = model(images.to(device))
loss = criterion(out, targets.to(device))
loss.backward()
optimizer.step()
if epoch % 10 == 0:
print('epoch: %3d loss: %.4f' % (epoch, loss))
return model
def accuracy(model, dataset):
model.eval()
correct = sum([(model(images.to(device)).argmax(dim=1) == targets.to(device)).sum()
for images, targets in DataLoader(dataset, batch_size=256)])
return correct.float() / len(dataset)
def getModel():
hidden_size = 500
model = nn.Sequential(
nn.Linear(imageSize[0] * imageSize[1] * 3, hidden_size),
nn.ReLU(),
nn.Linear(hidden_size, len(labels)),
nn.LogSoftmax(dim=-1)
).to(device)
return model
def saveModel(model, path):
print("Saving model")
torch.save(model.state_dict(), path)
def loadModel(path):
print("Loading model")
model = getModel()
model.load_state_dict(torch.load(path))
return model
def trainNewModel(n_iter=100, batch_size=256):
trainset = getDataset(True)
model = getModel()
model = train(model, trainset)
return model
def predictLabel(imagePath, model):
image = Image.open(imagePath).convert("RGB")
image = preprocess_image(image)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
with torch.no_grad():
model.eval() # Ustawienie modelu w tryb ewaluacji
output = model(image)
# Znalezienie indeksu klasy o największej wartości prawdopodobieństwa
predicted_class = torch.argmax(output).item()
return labels[predicted_class]
# Znalezienie indeksu klasy o największej wartości prawdopodobieństwa
predicted_class = torch.argmax(output).item()
return labels[predicted_class]
def preprocess_image(image):
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
transform = getTransformation()
image = transform(image).unsqueeze(0) # Add batch dimension
image = image.to(device) # Move the image tensor to the same device as the model
return image

7
readme.txt Normal file
View File

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

Binary file not shown.

Binary file not shown.

BIN
testModels/modelMPS.pth Normal file

Binary file not shown.

BIN
testModels/modelMPS650.pth Normal file

Binary file not shown.

BIN
testModels/modelMPS_AL.pth Normal file

Binary file not shown.

87
treeData.py Normal file
View File

@ -0,0 +1,87 @@
tab = []
def iter(odp, i):
if i == 0:
j = ""
for k in range(0, 101, 28):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 1:
j = ""
for k in range(0, 101, 28):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 2:
j = ""
for k in range(2):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 3:
j = ""
for k in range(0, 101, 34):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 4:
j = ""
for k in range(0, 101, 40):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 5:
j = ""
for k in range(0, 4, 2):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 6:
j = ""
for k in range(0, 4, 2):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 7:
j = ""
for k in range(0, 4, 2):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 8:
j=""
for k in range(4):
odp += f"{k},"
odp = iter(odp, i + 1)
j = str(k)
odp = odp[:-(len(j) + 1)]
return odp
if i == 9:
global licznik
x = odp.split(",")
if (int(x[0]) > 60 or int(x[1]) > 90 or int(x[2]) == 1 or int(x[3]) > 70 or int(x[4]) <= 10 or int(x[5]) == 0 or int(x[5]) == 4 or int(x[6]) == 2 or int(x[6]) == 3 or int(x[7]) == 0 or int(x[8]) == 1):
odp += "0"
else:
odp += "1"
print(odp)
tab.append(odp)
licznik += 1
return odp[:-1]
iter("", 0)