61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
|
import random
|
||
|
from classes.Trash import *
|
||
|
|
||
|
|
||
|
class Garbage:
|
||
|
def __init__(self):
|
||
|
self.content = []
|
||
|
self.predict = []
|
||
|
self.prob: float = 0.3
|
||
|
|
||
|
def getContent(self):
|
||
|
return self.content
|
||
|
|
||
|
def setContent(self, content):
|
||
|
self.content = content
|
||
|
return self
|
||
|
|
||
|
def addContent(self, item: Trash):
|
||
|
self.content.append(item)
|
||
|
return self
|
||
|
|
||
|
def removeContent(self, item: int):
|
||
|
return self.content.pop(item)
|
||
|
|
||
|
def getPredict(self):
|
||
|
return self.predict
|
||
|
|
||
|
def setPredict(self, predict):
|
||
|
self.predict = predict
|
||
|
return self
|
||
|
|
||
|
def addPredict(self, item):
|
||
|
self.predict.append(item)
|
||
|
return self
|
||
|
|
||
|
def getProb(self):
|
||
|
return self.prob
|
||
|
|
||
|
def setProb(self, prob):
|
||
|
self.prob = prob
|
||
|
return self
|
||
|
|
||
|
def generatePredict(self, i=random.choice([2, 3])):
|
||
|
if i < 0:
|
||
|
self.predict.pop(i)
|
||
|
else:
|
||
|
for _ in range(i):
|
||
|
possible = [Papier(), MetalPlastik(), Szklo(), Mixed(), Bio()]
|
||
|
traf = random.choice(possible)
|
||
|
self.predict.append(traf)
|
||
|
for bruh in possible:
|
||
|
if bruh != traf:
|
||
|
del bruh
|
||
|
|
||
|
|
||
|
def generateContent(self):
|
||
|
mod = random.choice([1, -1])
|
||
|
self.setContent(self.predict[:])
|
||
|
if random.random() < self.prob:
|
||
|
self.generatePredict(mod)
|