Madra_smieciarka/classes/Garbage.py

67 lines
1.6 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.full = random.randint(0, 2)
2024-03-25 11:21:23 +01:00
self.content = []
self.known = []
2024-03-25 11:21:23 +01:00
self.prob: float = 0.3
self.generateKnown()
2024-03-25 11:39:10 +01:00
self.generateContent()
self.known = tuple(self.known)
2024-03-25 11:21:23 +01:00
def getContent(self):
return self.content
def getFull(self):
return self.full
2024-03-25 11:21:23 +01:00
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)
2024-03-25 11:21:23 +01:00
def getKnown(self):
return self.known
2024-03-25 11:21:23 +01:00
def setKnown(self, predict):
self.known = predict
2024-03-25 11:21:23 +01:00
return self
def addKnown(self, item):
self.known.append(item)
2024-03-25 11:21:23 +01:00
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])):
2024-03-25 11:21:23 +01:00
if i < 0:
self.known.pop(i)
2024-03-25 11:21:23 +01:00
else:
for _ in range(i):
possible = [Papier(), MetalPlastik(), Szklo(), Mixed(), Bio()]
traf = random.choice(possible)
self.known.append(traf)
2024-03-25 11:21:23 +01:00
for bruh in possible:
if bruh != traf:
del bruh
def generateContent(self):
self.setContent(self.known[:])
2024-03-25 11:21:23 +01:00
if random.random() < self.prob:
mod = random.choice([1, -1])
self.generateKnown(mod)