Exemplo n.º 1
0
    def pursuit(self, evader):
        evader.mode = 'wander'

        ## OPTIONAL EXTRA... pursuit (you'll need something to pursue!)
        self.toEvader = evader.pos - self.pos
        self.relHeading = Vector2D.dot(evader.heading, self.heading)

        if(Vector2D.dot(self.toEvader, self.heading) > 0 and self.relHeading < -0.95):
            return self.seek(evader.pos)

        lookAheadTime = Vector2D.length(self.toEvader) / (self.max_speed + evader.speed())
        return self.seek(evader.pos + evader.vel * lookAheadTime)
Exemplo n.º 2
0
    def pursuit(self, evader):
        ''' this behaviour predicts where an agent will be in time T and seeks
            towards that point to intercept it. '''
        evader.mode = 'flee'
## OPTIONAL EXTRA... pursuit (you'll need something to pursue!)
        self.toEvader = evader.pos - self.pos
        self.relHeading = Vector2D.dot(evader.heading, self.heading)

        if(Vector2D.dot(self.toEvader, self.heading) > 0 and self.relHeading < -0.95):
            return self.seek(evader.pos)

        lookAheadTime = Vector2D.length(self.toEvader) / (self.max_speed + evader.speed())
        return self.seek(evader.pos + evader.vel * lookAheadTime)
Exemplo n.º 3
0
    def pursuit(self, evader):
        ''' this behaviour predicts where an agent will be in time T and seeks
            towards that point to intercept it. '''
        evader.mode = 'flee'
        ## OPTIONAL EXTRA... pursuit (you'll need something to pursue!)
        self.toEvader = evader.pos - self.pos
        self.relHeading = Vector2D.dot(evader.heading, self.heading)

        if (Vector2D.dot(self.toEvader, self.heading) > 0
                and self.relHeading < -0.95):
            return self.seek(evader.pos)

        lookAheadTime = Vector2D.length(
            self.toEvader) / (self.max_speed + evader.speed())
        return self.seek(evader.pos + evader.vel * lookAheadTime)