def i_can_see(self, point):
        pos, com, success = self.perception
        if self.phase == 2:
            point = point.copy() - self.position
        elif self.phase > 2:
            point = self.transform(point.copy() - self.position)
        else:
            point = point.copy()

        return lineofsight(point,array([0,0]),pos)
Beispiel #2
0
    def drawocclusionshading(self, cc, state):
        if self.selectedbee is not None:
            pos = next((x[0] for x in state if x[1] is self.selectedbee), None)
            positions, bees, movement, communication = map(list, zip(*state))

            xmin,ymin = self.fi(array([0,0]))
            xmax,ymax = self.fi(array([1,1]))

            for square in iterprod(range(int(xmin)-2,int(xmax)+2),
                                        range(int(ymin)-2,int(ymax)+2)):
                square = array(square)

                if not lineofsight(pos, square, positions):
                    x,y = self.f(square)
                    
                    cc.save()
                    cc.translate(x,y)
                    cc.scale(1/self.worldsize[0], 1/self.worldsize[1])

                    cc.rectangle(-0.5,-0.5,1,1)
                    
                    cc.restore()
                    cc.set_source_rgb(0.9, 0.9, 0.9)
                    cc.fill()