2021-06-13 15:14:55 +02:00
|
|
|
import random
|
|
|
|
from house import is_house
|
|
|
|
|
|
|
|
|
|
|
|
class Trash:
|
|
|
|
def __init__(self, grid_w, grid_h, grid_size):
|
|
|
|
self.grid_w = grid_w
|
|
|
|
self.grid_h = grid_h
|
|
|
|
self.size = grid_size
|
|
|
|
|
2021-06-15 20:24:06 +02:00
|
|
|
def new_pos(self, truck_pos, houses, multi):
|
2021-06-13 15:14:55 +02:00
|
|
|
while True:
|
|
|
|
self.pos = [random.randrange(0, self.grid_w, self.size),
|
|
|
|
random.randrange(0, self.grid_h, self.size)]
|
2021-06-15 20:24:06 +02:00
|
|
|
if self.pos != truck_pos and not is_house(self.pos, houses) and self not in multi:
|
2021-06-13 15:14:55 +02:00
|
|
|
break
|
2021-06-15 20:24:06 +02:00
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
if isinstance(self, Trash):
|
|
|
|
return self.pos == other.pos
|
|
|
|
return False
|