Zaktualizuj 'Traktorek/ran.py'
This commit is contained in:
parent
a049664f20
commit
14f6ffd430
@ -62,6 +62,10 @@ class Game(object):
|
|||||||
pygame.draw.line(self.screen, color, (krat, 0), (krat, 720), 1)
|
pygame.draw.line(self.screen, color, (krat, 0), (krat, 720), 1)
|
||||||
|
|
||||||
def randomize_field(self):
|
def randomize_field(self):
|
||||||
|
ileDni = []
|
||||||
|
uprawa = []
|
||||||
|
uprawaDni = []
|
||||||
|
woda = []
|
||||||
for x in range(25):
|
for x in range(25):
|
||||||
temp = []
|
temp = []
|
||||||
# nasiona
|
# nasiona
|
||||||
@ -70,27 +74,55 @@ class Game(object):
|
|||||||
temp.append(random.choice([True, False]))
|
temp.append(random.choice([True, False]))
|
||||||
# woda
|
# woda
|
||||||
temp.append(random.choice([True, False]))
|
temp.append(random.choice([True, False]))
|
||||||
|
# ile dni temu pole bylo podlewane
|
||||||
|
temp.append(random.randrange(7))
|
||||||
# # growth rate
|
# # growth rate
|
||||||
# temp.append(random)
|
# temp.append(random)
|
||||||
# # cost
|
# # cost
|
||||||
if temp[0] == "żyto":
|
if temp[0] == "żyto":
|
||||||
temp.append(10)
|
temp.append(10)
|
||||||
|
temp.append(4)
|
||||||
elif temp[0] == "jęczmień":
|
elif temp[0] == "jęczmień":
|
||||||
temp.append(12)
|
temp.append(12)
|
||||||
|
temp.append(3)
|
||||||
elif temp[0] == "owies":
|
elif temp[0] == "owies":
|
||||||
temp.append(8)
|
temp.append(8)
|
||||||
|
temp.append(2)
|
||||||
elif temp[0] == "marchew":
|
elif temp[0] == "marchew":
|
||||||
temp.append(14)
|
temp.append(14)
|
||||||
|
temp.append(5)
|
||||||
elif temp[0] == "rzodkiew":
|
elif temp[0] == "rzodkiew":
|
||||||
temp.append(7)
|
temp.append(7)
|
||||||
|
temp.append(5)
|
||||||
elif temp[0] == "pietruszka":
|
elif temp[0] == "pietruszka":
|
||||||
temp.append(6)
|
temp.append(6)
|
||||||
|
temp.append(1)
|
||||||
elif temp[0] == "puste":
|
elif temp[0] == "puste":
|
||||||
temp.append(2)
|
temp.append(2)
|
||||||
|
temp.append(6)
|
||||||
else:
|
else:
|
||||||
temp.append(0)
|
temp.append(0)
|
||||||
|
|
||||||
self.fields.append(temp)
|
self.fields.append(temp)
|
||||||
|
uprawa.append(temp[0])
|
||||||
|
ileDni.append(temp[3])
|
||||||
|
uprawaDni.append(temp[6])
|
||||||
|
woda.append(temp[2])
|
||||||
|
print(self.fields)
|
||||||
|
print(uprawa)
|
||||||
|
print(ileDni)
|
||||||
|
print(uprawaDni)
|
||||||
|
nawadnianie = pd.DataFrame({"uprawa": uprawa, "ileDni": ileDni, "uprawaDni": uprawaDni, "woda": woda})
|
||||||
|
nawadnianie["uprawa"], uprawa_kody=pd.factorize(nawadnianie["uprawa"])
|
||||||
|
nawadnianie["ileDni"], ileDni_kody = pd.factorize(nawadnianie["ileDni"])
|
||||||
|
nawadnianie["uprawaDni"], uprawaDni_kody = pd.factorize(nawadnianie["uprawaDni"])
|
||||||
|
nawadnianie["woda"], woda_kody = pd.factorize(nawadnianie["woda"])
|
||||||
|
X = nawadnianie.drop(["woda"], axis=1)
|
||||||
|
y = nawadnianie["woda"]
|
||||||
|
klasyfikator = DecisionTreeClassifier(criterion="entropy")
|
||||||
|
klasyfikator.fit(X=X, y=y)
|
||||||
|
print(klasyfikator.predict(X))
|
||||||
|
#if(klasyfikator.predict(X)[n]==0):
|
||||||
|
|
||||||
def draw_field(self):
|
def draw_field(self):
|
||||||
for x in range(25):
|
for x in range(25):
|
||||||
|
Loading…
Reference in New Issue
Block a user