Madra_smieciarka/classes/Garbage.py

63 lines
1.5 KiB
Python
Raw Normal View History

2024-03-25 11:21:23 +01:00
import random
from classes.Trash import *
class Garbage:
def __init__(self):
self.content = []
self.predict = []
self.prob: float = 0.3
2024-03-25 11:39:10 +01:00
self.generatePredict()
self.generateContent()
self.predict = tuple(self.predict)
2024-03-25 11:21:23 +01:00
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):
self.setContent(self.predict[:])
if random.random() < self.prob:
mod = random.choice([1, -1])
2024-03-25 11:21:23 +01:00
self.generatePredict(mod)