This commit is contained in:
s444426 2020-06-09 19:34:29 +02:00
parent 0b0ee6612b
commit 2bae8269f2
2 changed files with 17 additions and 4 deletions

View File

@ -10,7 +10,7 @@ from sklearn.tree import export_graphviz
def decision(plant,feed,growth,dryness): def decision(plant,feed,growth,dryness):
# czytanie pliku csv # czytanie pliku csv
df = pd.read_csv("C:\DATA\#Mike\#Studia\#Rok II- Semestr II\#Sztuczna_inteligencja\Projekt\AIProjekt\data.csv") df = pd.read_csv("data.csv")
#print(df) #print(df)
#zmiana słów na cyfry, ponieważ drzewo decyzyjne opiera się na cyfrach #zmiana słów na cyfry, ponieważ drzewo decyzyjne opiera się na cyfrach

19
main.py
View File

@ -1,7 +1,8 @@
import pygame, sys import pygame, sys
from traktor import Traktor from traktor import Traktor
import dijkstra as di import dijkstra as di
import decisiontree as dt import decisiontree as dt
from ID3 import predict_data
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from tensorflow.keras.preprocessing import image from tensorflow.keras.preprocessing import image
@ -47,9 +48,11 @@ class Game(object):
#ładowanie tablicy ze zdjeciami #ładowanie tablicy ze zdjeciami
imgs = [] imgs = []
data_plant = [] data_plant = []
data_soil = []
img_dir = './imgs' img_dir = './imgs'
for _ in lokalizacje: for _ in lokalizacje:
data_plant.append([random.randrange(5, 90),random.randrange(0, 120),random.randrange(5, 90)]) data_plant.append([random.randrange(5, 90),random.randrange(0, 120),random.randrange(5, 90)])
data_soil.append([random.randrange(44, 75)/10, random.randrange(0, 100)/100])
imgs.append(img_dir + '/' + random.choice(os.listdir(img_dir))) imgs.append(img_dir + '/' + random.choice(os.listdir(img_dir)))
#model do rozpoznawania #model do rozpoznawania
@ -145,8 +148,18 @@ class Game(object):
list_of_preds = preds.tolist()[0] list_of_preds = preds.tolist()[0]
index = list_of_preds.index(max(list_of_preds)) index = list_of_preds.index(max(list_of_preds))
#print(index) #print(index)
names = ['cabbage', 'beetroot', 'carrot', 'pumpkin']
# decyzja o posadzeniu nowej rośliny następuje wtedy, gdy jest ona dojrzała przynajmniej w 90%
if(data_plant[pt][1] > 90):
predict_data([names[index], data_soil[pt][0], data_soil[pt][1]])
index = names.index(names[index])
#imgs[pt] = img_dir + '/' + names[index] + '.jpg'
data_plant[pt] = [0, 0, 50]
else:
print("Planted: none")
if index == 0: if index == 0:
dt.decision(4, data_plant[pt][0],data_plant[pt][1],data_plant[pt][2]) dt.decision(4, data_plant[pt][0],data_plant[pt][1],data_plant[pt][2])
if index == 1: if index == 1: