Madra_smieciarka/classes/Garbage.py
Neerka 8c37aaea5d tree complete
Signed-off-by: Neerka <kuba.markil0220@gmail.com>
2024-05-13 15:05:11 +02:00

67 lines
1.6 KiB
Python

import random
from classes.Trash import *
class Garbage:
def __init__(self):
self.full = random.randint(0, 2)
self.content = []
self.known = []
self.prob: float = 0.3
self.generateKnown()
self.generateContent()
self.known = tuple(self.known)
def getContent(self):
return self.content
def getFull(self):
return self.full
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.remove(item)
def getKnown(self):
return self.known
def setKnown(self, predict):
self.known = predict
return self
def addKnown(self, item):
self.known.append(item)
return self
def getProb(self):
return self.prob
def setProb(self, prob):
self.prob = prob
return self
def generateKnown(self, i=random.choice([2, 3])):
if i < 0:
self.known.pop(i)
else:
for _ in range(i):
possible = [Papier(), MetalPlastik(), Szklo(), Mixed(), Bio()]
traf = random.choice(possible)
self.known.append(traf)
for bruh in possible:
if bruh != traf:
del bruh
def generateContent(self):
self.setContent(self.known[:])
if random.random() < self.prob:
mod = random.choice([1, -1])
self.generateKnown(mod)