def driftMood(self, dt = None, curMood = None):
        now = globalClock.getFrameTime()
        if not hasattr(self, 'lastDriftTime'):
            self.lastDriftTime = now
        if dt is None:
            dt = now - self.lastDriftTime
        self.lastDriftTime = now
        if dt <= 0.0:
            return
        if curMood is None:
            curMood = self

        def doDrift(curValue, timeToMedian, dt = float(dt)):
            newValue = curValue + dt / (timeToMedian * 7200)
            return min(max(newValue, 0.0), 1.0)

        self.boredom = doDrift(curMood.boredom, self.tBoredom)
        self.loneliness = doDrift(curMood.loneliness, self.tLoneliness)
        self.sadness = doDrift(curMood.sadness, self.tSadness)
        self.fatigue = doDrift(curMood.fatigue, self.tFatigue)
        self.hunger = doDrift(curMood.hunger, self.tHunger)
        self.confusion = doDrift(curMood.confusion, self.tConfusion)
        self.excitement = doDrift(curMood.excitement, self.tExcitement)
        self.surprise = doDrift(curMood.surprise, self.tSurprise)
        self.affection = doDrift(curMood.affection, self.tAffection)
        abuse = average(curMood.hunger, curMood.hunger, curMood.hunger, curMood.boredom, curMood.loneliness)
        tipPoint = 0.6
        if abuse < tipPoint:
            tAnger = lerp(self.tAngerDec, -PetMood.LONGTIME, abuse / tipPoint)
        else:
            tAnger = lerp(PetMood.LONGTIME, self.tAngerInc, (abuse - tipPoint) / (1.0 - tipPoint))
        self.anger = doDrift(curMood.anger, tAnger)
        self.announceChange()
        return
    def driftMood(self, dt=None, curMood=None):
        # Pass in a dt to simulate mood over a specific amount of time.
        # If dt not passed in, simulates based on time elapsed since last call.
        # Typical call pattern:
        # driftMood(timeSinceLastSeen)
        # driftMood()
        # driftMood()
        # ...
        #
        # If you want to calculate mood drift using another PetMood as the
        # starting point, pass it in as curMood. This is the recommended
        # method for simulating mood on the client, where the results are
        # not being stored in the database:
        # driftMood(timeSinceLastSeen(), lastMood)
        # ...
        # driftMood(timeSinceLastSeen(), lastMood)
        # ...
        # driftMood(timeSinceLastSeen(), lastMood)
        #
        # The resulting mood will match the mood calculated by the AI
        # (using the first method, above) when the pet comes into existence

        # TODO: add variation to this. Over long dt's, add in a sine wave,
        # some random noise, etc.

        #print "dt is %s" % dt
        now = globalClock.getFrameTime()
        if not hasattr(self, 'lastDriftTime'):
            self.lastDriftTime = now
        if dt is None:
            dt = now - self.lastDriftTime
        self.lastDriftTime = now

        if dt <= 0.:
            return

        if __debug__:
            try:
                dt *= simbase.petMoodTimescale
            except:
                pass

        if curMood is None:
            curMood = self

        # linear motion, for now
        def doDrift(curValue, timeToMedian, dt=float(dt)):
            # mood = mood + secs/((hrs/2*(mood/2))*(secs/hr))
            """ use this to make sure that the numbers are even moving
            print curValue - (curValue + dt/(timeToMedian*7200))
            """
            newValue = curValue + dt / (timeToMedian * 7200)  #3600)#60*60)
            return clampScalar(newValue, 0., 1.)

        self.boredom = doDrift(curMood.boredom, self.tBoredom)
        # these are currently never used
        #self.restlessness = doDrift(curMood.restlessness, self.tRestlessness)
        #self.playfulness  = doDrift(curMood.playfulness, self.tPlayfulness)
        self.loneliness = doDrift(curMood.loneliness, self.tLoneliness)
        self.sadness = doDrift(curMood.sadness, self.tSadness)
        self.fatigue = doDrift(curMood.fatigue, self.tFatigue)
        self.hunger = doDrift(curMood.hunger, self.tHunger)
        self.confusion = doDrift(curMood.confusion, self.tConfusion)
        self.excitement = doDrift(curMood.excitement, self.tExcitement)
        self.surprise = doDrift(curMood.surprise, self.tSurprise)
        self.affection = doDrift(curMood.affection, self.tAffection)

        # for the sake of long-haul calculations, do the feedback calcs
        # after the simple independent calcs
        abuse = average(curMood.hunger, curMood.hunger, curMood.hunger,
                        curMood.boredom, curMood.loneliness)
        tipPoint = .6
        if abuse < tipPoint:
            tAnger = lerp(self.tAngerDec, -PetMood.LONGTIME, abuse / tipPoint)
        else:
            tAnger = lerp(PetMood.LONGTIME, self.tAngerInc,
                          (abuse - tipPoint) / (1. - tipPoint))
        self.anger = doDrift(curMood.anger, tAnger)

        self.announceChange()