def calcAction(self): self.brain.calcAction() a = self.brain.action d = self.distancePercept(self.percepts) # Compute the distance as a fraction of "farDistance" dFrac = min(1.0, d/self.farDistance) angle = util2D.angle(a.direction) + dFrac + math.pi*random.random() - 0.5*math.pi self.action.setDirection(util2D.dir(angle, self.tmp)) # TODO: pass in desired distribution (and associated parameters) to the constructor # Add more variance when the tagged character is far away, e.g. # # stdMax = 130 # std = min(stdMax, stdMax * d/farDistance) # # v = utile2D.normalDir(util2D.angle(v), std) # TODO: consider randomizing speed too? Or make separate randomizeDirection # and randomizeSpeed? assert 0 < a.speed self.action.setSpeed(a.speed)
def drawCircle(center, orientation, radius): global quadric glPushMatrix() glTranslate(center[0], center[1], 0.0) glRotate(util.radToDeg(util2D.angle(orientation)), 0, 0, 1) gluPartialDisk(quadric, 0.0, radius, 20, 1, 0.0, 360.0) glPopMatrix()