87 lines
2.0 KiB
Python
87 lines
2.0 KiB
Python
import numpy as np
|
|
import pygame
|
|
|
|
class trash():
|
|
def __init__(self):
|
|
self.id = 0
|
|
self.plastic = 0
|
|
self.paper = 0
|
|
self.mixed = 0
|
|
self.organic = 0
|
|
self.glass = 0
|
|
self.color = 0
|
|
self.xy = 0
|
|
self.value = 1
|
|
self.numberx = 0
|
|
self.numbery = 0
|
|
|
|
def giveID(self,id):
|
|
self.id = id
|
|
|
|
|
|
|
|
def throwAway(self):
|
|
trash = np.random.randint(1,6)
|
|
if trash == 1:
|
|
self.plastic += 1
|
|
return True
|
|
elif trash == 2:
|
|
self.paper += 1
|
|
return True
|
|
elif trash == 3:
|
|
self.glass += 1
|
|
return True
|
|
elif trash == 4:
|
|
self.organic += 1
|
|
return True
|
|
elif trash == 5:
|
|
self.mixed += 1
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
|
|
def empty(self):
|
|
if self.plastic > 0:
|
|
self.plastic -= 1
|
|
print("taking plastic")
|
|
return True
|
|
elif self.paper > 0:
|
|
self.paper -= 1
|
|
print("taking paper")
|
|
return True
|
|
elif self.glass > 0:
|
|
self.glass -= 1
|
|
print("taking glass")
|
|
return True
|
|
elif self.organic > 0:
|
|
self.organic -= 1
|
|
print("taking organic")
|
|
return True
|
|
elif self.mixed > 0:
|
|
self.mixed -= 1
|
|
print("taking mixed")
|
|
return True
|
|
else:
|
|
print("can't take trash from this dumpster")
|
|
return False
|
|
|
|
def colour(self):
|
|
if self.plastic > 0:
|
|
self.color = 1
|
|
return True
|
|
elif self.paper > 0:
|
|
self.color = 2
|
|
return True
|
|
elif self.glass > 0:
|
|
self.color = 3
|
|
return True
|
|
elif self.organic > 0:
|
|
self.color = 4
|
|
return True
|
|
elif self.mixed > 0:
|
|
self.color = 5
|
|
return True
|
|
else:
|
|
return False
|