class Cell(): def __init__(self, x, y): self.x = x self.y = y self.condition = Cell_Condition() def set_lichens(self): lichen_tab = [] if self.condition.infected(): lichen_tab.append(Lichen(self.x - 1, self.y)) lichen_tab.append(Lichen(self.x + 1, self.y)) lichen_tab.append(Lichen(self.x, self.y - 1)) lichen_tab.append(Lichen(self.x, self.y + 1)) return lichen_tab def can_get_lichen(self, lichen): return lichen.target_x == self.x and lichen.target_y == self.y def apply_lichen(self, lichen): if lichen.target_x != self.x or lichen.target_y != self.y: raise Exception("DEBUG :: Lichen error: " + str(self.x) + "," + str(self.y) + " -> " + str(lichen.target_x) + "," + str(lichen.target_y)) elif self.condition.protected(): return False elif self.condition.is_healthy(): if random.random() < lichen.chance: self.condition.infect() return True return False def update(self): self.condition.update_condition() def can_infect_others(self): return self.condition.infected() def get_condition(self): return str(self.condition)