Beispiel #1
0
    def update(self):
        cid: int = self.cell_id

        if self.is_new:
            self.create_candidates()
        elif self.action == 1:
            cells[cid].agent_ = DeviceAllocator.new(Candidate, cid)
            DeviceAllocator.destroy(self)
Beispiel #2
0
    def maybe_create_candidate(self, x: int, y: int):
        dx: int = -1
        dy: int = -1
        while dx < 2:
            while dy < 2:
                nx: int = x + dx
                ny: int = y + dy

                if -1 < nx < SIZE_X and -1 < ny < SIZE_Y:
                    if cells[ny * SIZE_X + nx].agent().is_alive:
                        alive: Alive = cells[ny * SIZE_X + nx].agent()
                        if alive.is_new:
                            if alive is self:
                                cells[y * SIZE_X + x].agent_ = DeviceAllocator.new(Candidate, y * SIZE_X + x)
                            return
                dy += 1
            dx += 1
Beispiel #3
0
 def update(self):
     cid: int = self.cell_id
     if self.action == 2:
         cells[cid].agent_ = DeviceAllocator.new(Alive, cid)
         cells[cid].agent_.is_alive = True
         DeviceAllocator.destroy(self)