Exemplo n.º 1
0
 def _process(self, dt):
     self.targetMoveCountdown -= dt
     if self.targetMoveCountdown <= 0.0:
         distance = normalDistrib(3.0, 30.0)
         heading = normalDistrib(-(90 + 45), 90 + 45)
         if self.gotCollision:
             self.gotCollision = False
             heading = heading + 180
         target = self.getTarget()
         target.setPos(self.getNodePath().getPos())
         target.setH(target, heading)
         target.setY(target, distance)
         duration = distance / self.mover.getFwdSpeed()
         self.targetMoveCountdown = duration * randFloat(1.2, 3.0)
     CPetChase.process(self, dt)
Exemplo n.º 2
0
    def _scheduleNextProfile(self):
        self._profileCounter += 1
        self._timeElapsed = self._profileCounter * self._period
        #assert isInteger(self._timeElapsed)
        time = self._startTime + self._timeElapsed

        # vary the actual delay between profiles by a random amount to prevent interaction
        # with periodic events
        jitter = self._jitter
        if jitter is None:
            jitter = normalDistrib(-self._jitterMagnitude,
                                   self._jitterMagnitude)
            time += jitter
        else:
            time -= jitter
            jitter = None
        self._jitter = jitter

        sessionId = serialNum()
        session = taskMgr.getProfileSession('FrameProfile-%s' % sessionId)
        self._id2session[sessionId] = session
        taskMgr.profileFrames(num=1,
                              session=session,
                              callback=Functor(self._analyzeResults,
                                               sessionId))

        # schedule the next profile
        delay = max(time - globalClock.getFrameTime(), 0.)
        self._task = taskMgr.doMethodLater(delay,
                                           self._scheduleNextProfileDoLater,
                                           'FrameProfiler-%s' % serialNum())
    def _scheduleNextProfile(self):
        self._profileCounter += 1
        self._timeElapsed = self._profileCounter * self._period
        assert isInteger(self._timeElapsed)
        time = self._startTime + self._timeElapsed

        # vary the actual delay between profiles by a random amount to prevent interaction
        # with periodic events
        jitter = self._jitter
        if jitter is None:
            jitter = normalDistrib(-self._jitterMagnitude, self._jitterMagnitude)
            time += jitter
        else:
            time -= jitter
            jitter = None
        self._jitter = jitter
            
        sessionId = serialNum()
        session = taskMgr.getProfileSession('FrameProfile-%s' % sessionId)
        self._id2session[sessionId] = session
        taskMgr.profileFrames(num=1, session=session, callback=Functor(
            self._analyzeResults, sessionId))

        # schedule the next profile
        delay = max(time - globalClock.getFrameTime(), 0.)
        self._task = taskMgr.doMethodLater(delay, self._scheduleNextProfileDoLater,
                                           'FrameProfiler-%s' % serialNum())
Exemplo n.º 4
0
    def _process(self, dt):
        self.targetMoveCountdown -= dt
        if self.targetMoveCountdown <= 0.:
            distance = normalDistrib(3., 30.)
            heading = normalDistrib(-(90 + 45), (90 + 45))

            # if we bumped into something, go in the opposite direction
            # from where we were about to go
            if self.gotCollision:
                self.gotCollision = False
                heading = heading + 180

            target = self.getTarget()
            target.setPos(self.getNodePath().getPos())
            target.setH(target, heading)
            target.setY(target, distance)

            duration = distance / self.mover.getFwdSpeed()
            self.targetMoveCountdown = duration * randFloat(1.2, 3.)

        CPetChase.process(self, dt)
Exemplo n.º 5
0
 def _scheduleNextProfile(self):
     self._profileCounter += 1
     self._timeElapsed = self._profileCounter * self._period
     time = self._startTime + self._timeElapsed
     jitter = self._jitter
     if jitter is None:
         jitter = normalDistrib(-(self._jitterMagnitude), self._jitterMagnitude)
         time += jitter
     else:
         time -= jitter
         jitter = None
     self._jitter = jitter
     sessionId = serialNum()
     session = taskMgr.getProfileSession('FrameProfile-%s' % sessionId)
     self._id2session[sessionId] = session
     taskMgr.profileFrames(num = 1, session = session, callback = Functor(self._analyzeResults, sessionId))
     delay = max(time - globalClock.getFrameTime(), 0.0)
     self._task = taskMgr.doMethodLater(delay, self._scheduleNextProfileDoLater, 'FrameProfiler-%s' % serialNum())
Exemplo n.º 6
0
 def _scheduleNextProfile(self):
     self._profileCounter += 1
     self._timeElapsed = self._profileCounter * self._period
     time = self._startTime + self._timeElapsed
     jitter = self._jitter
     if jitter is None:
         jitter = normalDistrib(-self._jitterMagnitude, self._jitterMagnitude)
         time += jitter
     else:
         time -= jitter
         jitter = None
     self._jitter = jitter
     sessionId = serialNum()
     session = taskMgr.getProfileSession('FrameProfile-%s' % sessionId)
     self._id2session[sessionId] = session
     taskMgr.profileFrames(num=1, session=session, callback=Functor(self._analyzeResults, sessionId))
     delay = max(time - globalClock.getFrameTime(), 0.0)
     self._task = taskMgr.doMethodLater(delay, self._scheduleNextProfileDoLater, 'FrameProfiler-%s' % serialNum())
     return
Exemplo n.º 7
0
def gaussian(min, max, rng):
    return normalDistrib(min, max, rng.gauss)
def gaussian(min, max, rng):
    return normalDistrib(min, max, rng.gauss)