implementation for 3rd individual project

This commit is contained in:
Kamila Bobkowska 2020-05-24 14:06:03 +00:00
parent 0270ceb6e3
commit 98d3b3ff2f

31
Main.py
View File

@ -8,6 +8,9 @@ from models.dumpster import trash
from models.Garbagetruck import GarbageTruck
import numbering
from sklearn.datasets import load_digits
import garbageDumpSorting as gds
import time
from models.garbageDump import Dump
#heuristics for finding the closest dumpster
def closest(GT, D):
@ -70,7 +73,7 @@ def drawGrid(grid, size):
elif grid[row][column] == 5:
#metal
img = garbageBLK
elif row == TheDump[:,0] and column == TheDump[:,1]:
elif row == dump.coor[:,0] and column == dump.coor[:,1]:
grid[row][column] = 0
img = recycImg
screen.blit(img, ((WIDTH) * row, (HEIGHT) * column))
@ -94,10 +97,20 @@ size=20
#randomizing coordinates, initializing the Garbage Dump
a = createDumpstersAndDump(20,size+1)
TheDump = np.reshape(a[-1], (1, 2))
dump = Dump()
dump.coor = np.reshape(a[-1], (1, 2))
a = np.reshape(a[:-1], (size, 2))
#Klaudia Przybylska subproject part
gds.createSets()
# gds.processTrainData()
# gds.processTestData()
clf = gds.trainAndTest()
time.sleep(5)
#Patryk Krawiec subproject part
digitsy=np.load("Ytest.npy")
digitsx=np.load("Xtest.npy")
@ -172,7 +185,7 @@ while not done:
Xz=np.where(all==x)[0]
x =[item for item, count in collections.Counter(Xz).items() if count > 1]
predicted=numbering.pred(dumpsters[x[0]].numberx,dumpsters[x[0]].numbery)
#recognizing whether a house is our client and trying to collect trash
if(predicted not in paying_customers):
print("House number is: ",predicted," but it is not our customer")
@ -189,7 +202,17 @@ while not done:
# visit Garbage Dump at the end
if len(a) == 0:
print("Going to the Garbage Dump")
display(grid, GT, TheDump)
display(grid, GT, dump.coor)
done = True
print("Checking garbage inside the truck: ")
gds.sortDump(GT.plastic, GT.paper, GT.metal, GT.cardboard, GT.glass, clf, GT, dump)
print("Garbage sorted: ")
print("Paper: " + str(dump.paper))
print("Cardboard: " + str(dump.cardboard))
print("Metal: " + str(dump.metal))
print("Plastic: " + str(dump.plastic))
print("Glass: " + str(dump.glass))
pygame.quit()