Exemple #1
0
    def inputInit(self):

        if 'Repeat' not in self.argDict:
            self.Repeat = 1

        self.t = 0

        compReg.getLock().acquire()
        xmin, ymin, xmax, ymax = compReg.getComponent('Screen').size
        compReg.getLock().release()

        xlen = xmax - xmin
        ylen = ymax - ymin

        if self['useClock']:
            self.t = self.clock()
            self.getTime = self.clockTick
        else:
            self.t = 0
            self.getTime = self.callTick

        self.x_eqn = eval('lambda t:' + str(xmin) + '+' + str(xlen) + '*(' +
                          str(self['xEquation']) + ')')
        self.y_eqn = eval('lambda t:' + str(ymin) + '+' + str(ylen) + '*(' +
                          str(self['yEquation']) + ')')
    def inputInit(self):
        xvals = {}
        yvals = {}
        compReg.getLock().acquire()
        xvals['left'], yvals['bottom'], xvals['right'], yvals['top'] = compReg.getComponent('Screen').getSize()
        compReg.getLock().release()
        (xvals['center'], yvals['center']) = ((xvals['left']+xvals['right']) / 2, (yvals['top']+yvals['bottom']) / 2)

        self.location = (xvals[self['xloc']], yvals[self['yloc']])
    def inputInit(self):
        compReg.getLock().acquire()
        xmin, ymin, xmax, ymax = compReg.getComponent('Screen').size
        compReg.getLock().release()

        xlen = xmax-xmin
        ylen = ymax-ymin

        self.xloc = xmin + xlen * self['xPos']
        self.yloc = ymin + ylen * self['yPos']
Exemple #4
0
    def inputInit(self):
        compReg.getLock().acquire()
        xmin, ymin, xmax, ymax = compReg.getComponent('Screen').size
        compReg.getLock().release()

        xlen = xmax - xmin
        ylen = ymax - ymin

        self.xloc = xmin + xlen * self['xPos']
        self.yloc = ymin + ylen * self['yPos']
Exemple #5
0
    def inputInit(self):
        xvals = {}
        yvals = {}
        compReg.getLock().acquire()
        xvals['left'], yvals['bottom'], xvals['right'], yvals[
            'top'] = compReg.getComponent('Screen').size
        compReg.getLock().release()
        (xvals['center'],
         yvals['center']) = ((xvals['left'] + xvals['right']) / 2,
                             (yvals['top'] + yvals['bottom']) / 2)

        self.location = (xvals[self['xloc']], yvals[self['yloc']])
    def inputInit(self):

        if 'Repeat' not in self.argDict:
            self.Repeat = 1

        self.t = 0

        compReg.getLock().acquire()
        xmin, ymin, xmax, ymax = compReg.getComponent('Screen').size
        compReg.getLock().release()

        xlen = xmax-xmin
        ylen = ymax-ymin

        if self['useClock']:
            self.t=self.clock()
            self.getTime = self.clockTick
        else:
            self.t=0
            self.getTime = self.callTick

        self.x_eqn = eval('lambda t:' + str(xmin) + '+' + str(xlen) + '*(' + str(self['xEquation']) + ')')
        self.y_eqn = eval('lambda t:' + str(ymin) + '+' + str(ylen) + '*(' + str(self['yEquation']) + ')')
Exemple #7
0
 def makeListener(self):
     try:
         compReg.getLock().acquire()
         compReg.getComponent(self['SensorNetworkId']).addListener(self)
         compReg.getLock().release()
         return True
     except Exception as ex:
         compReg.getLock().release()
         return False
 def makeListener(self):
     try:
         compReg.getLock().acquire()
         compReg.getComponent(self['LocSensorId']).addListener(self)
         compReg.getLock().release()
         return True
     except Exception as ex:
         compReg.getLock().release()
         return False
 def inputInit(self):
     compReg.getLock().acquire()
     minX,minY,maxX,maxY = compReg.getComponent('Screen').size
     compReg.getLock().release()
     self.center = ((minX+maxX) / 2, (minY+maxY) / 2)
 def inputInit(self):
     compReg.getLock().acquire()
     self.minX, self.minY, self.maxX, self.maxY = compReg.getComponent('Screen').size
     compReg.getLock().release()
 def inputInit(self):
     compReg.getLock().acquire()
     minX, minY, maxX, maxY = compReg.getComponent('Screen').size
     compReg.getLock().release()
     self.center = ((minX + maxX) / 2, (minY + maxY) / 2)
Exemple #12
0
 def inputInit(self):
     compReg.getLock().acquire()
     self.minX, self.minY, self.maxX, self.maxY = compReg.getComponent('Screen').size
     compReg.getLock().release()
Exemple #13
0
    def processResponse(self, sensor, recurs):
        ret = []

        if self['GrowthDirection'] != None:
            growthDirection = self['GrowthDirection']
        else:
            growthDirection = 'right'
        if self['HitSensitivity'] != None:
            hitSensitivity = self['HitSensitivity']
        else:
            hitSensitivity = 4
        if self['MaxVelocity'] != None:
            maxVelocity = self['MaxVelocity']
        else:
            maxVelocity = 10
        if self['MinVelocity'] != None:
            minVelocity = self['MinVelocity']
        else:
            minVelocity = -1
        if self['MinLength'] != None:
            minLength = self['MinLength']
        else:
            minLength = 30

        for sensory in sensor:
            opsensory = dict(sensory)

            if not 'XVel' in opsensory:
                opsensory['XVel'] = -1
            if not 'SpeedupTimer' in opsensory:
                opsensory['SpeedupTimer'] = 0
 
            if growthDirection == 'right':
                results = bqs.query([
                    bqs.getBehaviorIdLambda('accelerate'),\
                    bqs.getDirectionLambda('-'),\
                    bqs.getLeftLambda(0)
                ])
            else:
                compReg.getLock().acquire()
                self.minX, self.minY, self.maxX, self.maxY = compReg.getComponent('Screen').size
                compReg.getLock().release()

                results = bqs.query([
                    bqs.getBehaviorIdLambda('accelerate'),\
                    bqs.getDirectionLambda('+'),\
                    bqs.getRightLambda(self.maxX)
                ])


            if results:
                opsensory['SpeedupTimer'] = hitSensitivity 

            if opsensory['SpeedupTimer'] > 0:
                opsensory['XVel'] = min(opsensory['XVel'] + 1, maxVelocity)
                opsensory['SpeedupTimer'] = opsensory['SpeedupTimer'] - 1
            else:
                opsensory['XVel'] = max(minVelocity, opsensory['XVel'] - 1)

            opsensory['Location'] = (opsensory['Location'][0], opsensory['Location'][1] + opsensory['XVel'])

            #Set min length
            if opsensory['Location'][1] <= minLength:
                opsensory['Location'] = (opsensory['Location'][0], minLength)

            ret.append(opsensory)
        return (ret, []) 
Exemple #14
0
    def processResponse(self, sensor, recurs):
        ret = []

        if self['GrowthDirection'] != None:
            growthDirection = self['GrowthDirection']
        else:
            growthDirection = 'right'
        if self['HitSensitivity'] != None:
            hitSensitivity = self['HitSensitivity']
        else:
            hitSensitivity = 4
        if self['MaxVelocity'] != None:
            maxVelocity = self['MaxVelocity']
        else:
            maxVelocity = 10
        if self['MinVelocity'] != None:
            minVelocity = self['MinVelocity']
        else:
            minVelocity = -1
        if self['MinLength'] != None:
            minLength = self['MinLength']
        else:
            minLength = 30

        for sensory in sensor:
            opsensory = dict(sensory)

            if not 'XVel' in opsensory:
                opsensory['XVel'] = -1
            if not 'SpeedupTimer' in opsensory:
                opsensory['SpeedupTimer'] = 0

            if growthDirection == 'right':
                results = bqs.query([
                    bqs.getBehaviorIdLambda('accelerate'),\
                    bqs.getDirectionLambda('-'),\
                    bqs.getLeftLambda(0)
                ])
            else:
                compReg.getLock().acquire()
                self.minX, self.minY, self.maxX, self.maxY = compReg.getComponent(
                    'Screen').size
                compReg.getLock().release()

                results = bqs.query([
                    bqs.getBehaviorIdLambda('accelerate'),\
                    bqs.getDirectionLambda('+'),\
                    bqs.getRightLambda(self.maxX)
                ])

            if results:
                opsensory['SpeedupTimer'] = hitSensitivity

            if opsensory['SpeedupTimer'] > 0:
                opsensory['XVel'] = min(opsensory['XVel'] + 1, maxVelocity)
                opsensory['SpeedupTimer'] = opsensory['SpeedupTimer'] - 1
            else:
                opsensory['XVel'] = max(minVelocity, opsensory['XVel'] - 1)

            opsensory['Location'] = (opsensory['Location'][0],
                                     opsensory['Location'][1] +
                                     opsensory['XVel'])

            #Set min length
            if opsensory['Location'][1] <= minLength:
                opsensory['Location'] = (opsensory['Location'][0], minLength)

            ret.append(opsensory)
        return (ret, [])