Esempio n. 1
0
 def processResponse(self, sensor, recurs):
     ret = []
     for sensory in sensor:
         opsensory = dict(sensory)
         isNew = self.insertStepIfMissing(opsensory) 
         #TODO: update 19 to be a configurable variable
         if opsensory['isNew'] <= 0:
             results = bqs.query([
                 bqs.getBehaviorIdLambda(self['Id']),\
                 bqs.getDifferentUIDLambda(opsensory['UniqueResponseIdentifier']),\
                 bqs.getDistLambda(opsensory['Location'], 19)
             ])
             if results:
                 opsensory['XStep'] = -opsensory['XStep']
                 opsensory['Location'] = Geo.addLocations((opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
         else:
             opsensory['isNew'] -= 1
         if isNew:
             opsensory['Location'] = Geo.addLocations((2*opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
             ret.append(opsensory)
             opsensory2 = dict(opsensory)
             opsensory2['XStep'] = -opsensory2['XStep']
             opsensory2['Location'] = Geo.addLocations((2*opsensory2['XStep'], opsensory2['YStep']), opsensory['Location']) 
             ret.append(opsensory2)
         else:
             opsensory['Location'] = Geo.addLocations((opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
             ret.append(opsensory)
     return (ret, []) 
Esempio n. 2
0
 def processResponse(self, sensor, recurs):
     ret = []
     for sensory in sensor:
         opsensory = dict(sensory)
         isNew = self.insertStepIfMissing(opsensory) 
         #TODO: update 19 to be a configurable variable
         if opsensory['isNew'] <= 0:
             results = bqs.query([
                 bqs.getBehaviorIdLambda(self['Id']),\
                 bqs.getDifferentUIDLambda(opsensory['UniqueResponseIdentifier']),\
                 bqs.getDistLambda(opsensory['Location'], 19)
             ])
             if results:
                 opsensory['XStep'] = -opsensory['XStep']
                 opsensory['Location'] = Geo.addLocations((opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
         else:
             opsensory['isNew'] -= 1
         if isNew:
             if opsensory['Direction'] != 0:
                 opsensory['Location'] = Geo.addLocations((2*opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
                 ret.append(opsensory)
                 opsensory2 = dict(opsensory)
                 opsensory2['XStep'] = -opsensory2['XStep']
                 opsensory2['Location'] = Geo.addLocations((2*opsensory2['XStep'], opsensory2['YStep']), opsensory['Location']) 
                 ret.append(opsensory2)
         else:
             opsensory['Location'] = Geo.addLocations((opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
             ret.append(opsensory)
     return (ret, []) 
Esempio n. 3
0
 def processResponse(self, sensor, recurs):
     ret = []
     for loc in sensor:
         oploc = dict(loc)
         self.insertVelIfMissing(oploc)
         oploc['Location'] = Geo.addLocations((oploc['XVel'], oploc['YVel']), oploc['Location']) 
         ret.append(oploc)
     return (ret, []) 
Esempio n. 4
0
 def processResponse(self, sensors, recursives):
     ret = []
     s = self['StepSize']
     for sensory in sensors:
         step = [random.randint(-s,s), random.randint(-s,s)]
         outdict = dict(sensory)
         outdict[Strings.LOCATION] = Geo.addLocations(step, outdict[Strings.LOCATION])
         ret.append(outdict)
     return (ret,recursives)
Esempio n. 5
0
 def processResponse(self, sensor, recurs):
     ret = []
     for sensory in sensor:
         opsensory = dict(sensory)
         self.insertStepIfMissing(opsensory) 
         #TODO: update 19 to be a configurable variable
         results = bqs.query([
             bqs.getBehaviorIdLambda(self['Id']),\
             bqs.getDifferentUIDLambda(opsensory['UniqueResponseIdentifier']),\
             bqs.getDistLambda(opsensory['Location'], 19)
         ])
         if results:
             print len(results)
             opsensory['XStep'] = -opsensory['XStep']
             opsensory['Location'] = Geo.addLocations((opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
         opsensory['Location'] = Geo.addLocations((opsensory['XStep'], opsensory['YStep']), opsensory['Location']) 
         ret.append(opsensory)
     return (ret, []) 
Esempio n. 6
0
    def processResponse(self, sensor, recurs):
        ret = []

        if self['NoBounceTime'] != None:
            noBounceTime = self['NoBounceTime']
        else:
            noBounceTime = 1000
        if self['BQSDistance'] != None:
            BQSDistance = self['BQSDistance']
        else:
            BQSDistance = 19


        for sensory in sensor:
            opsensory = dict(sensory)

            isNew = self.insertVelIfMissing(opsensory) 
            if not 'NoBounceTime' in opsensory:
                opsensory['NoBounceTime'] = noBounceTime 

            if opsensory['NoBounceTime'] <= 0:
                results = bqs.query([
                    bqs.getBehaviorIdLambda(self['Id']),\
                    bqs.getDifferentUIDLambda(opsensory['UniqueResponseIdentifier']),\
                    bqs.getDistLambda(opsensory['Location'], BQSDistance)
                ])
                if results:
                    opsensory['XVel'] = -opsensory['XVel']
                    opsensory['Location'] = Geo.addLocations((opsensory['XVel'], opsensory['YVel']), opsensory['Location']) 
            else:
                opsensory['NoBounceTime'] -= 1
            if isNew:
                if opsensory['Direction'] < 0:
                    opsensory['XVel'] = -opsensory['XVel']
                if opsensory['Direction'] != 0:
                    opsensory['Location'] = Geo.addLocations((2*opsensory['XVel'], opsensory['YVel']), opsensory['Location']) 
                    ret.append(opsensory)
            else:
                opsensory['Location'] = Geo.addLocations((opsensory['XVel'], opsensory['YVel']), opsensory['Location']) 
                ret.append(opsensory)
        return (ret, []) 
Esempio n. 7
0
 def processResponse(self, sensor, recurs):
     ret = []
     for loc in sensor:
         oploc = dict(loc)
         self.insertVelIfMissing(oploc)
         deltaT = timeOps.time() - oploc["EvalTime"]
         deltaLoc = (deltaT * oploc["XVel"], deltaT * oploc["YVel"])
         # print 'diff:',deltaLoc
         oploc["Location"] = Geo.addLocations(deltaLoc, oploc["Location"])
         oploc["EvalTime"] = timeOps.time()
         ret.append(oploc)
     return (ret, [])
Esempio n. 8
0
 def processResponse(self, sensor, recurs):
     ret = []
     for loc in sensor:
         oploc = dict(loc)
         self.insertVelIfMissing(oploc)
         deltaT = timeOps.time() - oploc['EvalTime']
         deltaLoc = (deltaT * oploc['XVel'], deltaT * oploc['YVel'])
         #print 'diff:',deltaLoc
         oploc['Location'] = Geo.addLocations(deltaLoc, oploc['Location'])
         oploc['EvalTime'] = timeOps.time()
         ret.append(oploc)
     return (ret, [])
Esempio n. 9
0
 def processResponse(self, sensorInputs, recursiveInputs):
     newResponses = sensorInputs 
     ret = []
     ret += newResponses
     for recurInput in recursiveInputs:
         outDict = dict(recurInput)
         if not 'Dir' in outDict:
             outDict['Dir'] = 1 #to the right
         if not 'StepSize' in outDict:
             outDict['StepSize'] = self['StepSize']
         outDict['Location']= Geo.addLocations(outDict['Location'],
         (outDict['StepSize']*outDict['Dir'],0))
         
         if not Geo.pointWithinBoundingBox(outDict['Location'], \
             compReg.getComponent('Screen').getSize()):
                 outDict['Dir'] *= -1
         ret.append(outDict)
     ret += newResponses
     return (ret, ret)
Esempio n. 10
0
 def processResponse(self, sensor, recurs):
     ret = []
     for sensory in sensor:
         opsensory = dict(sensory)
         #TODO: update 19 to be a configurable variable
         self.insertVelIfMissing(opsensory)
         results = bqs.query([
             bqs.getBehaviorIdLambda('accelerate'),\
             bqs.getDirectionLambda('+'),\
             bqs.getDistLambda(opsensory['Location'], 38)
         ])
         if results:
             opsensory['XVel'] = opsensory['XVel'] + 10 
         opsensory['XVel'] = min(max(-1, opsensory['XVel'] - 1), 10)
         opsensory['Location'] = Geo.addLocations((-opsensory['XVel'], 0), opsensory['Location'])
         if opsensory['Location'][0] >= 800: #TODO: Make this dynamic
             opsensory['Location'] = tuple([799, 25])
         ret.append(opsensory)
     return (ret, []) 
Esempio n. 11
0
 def processResponse(self, sensorInputs, recursiveInputs):
     newResponses = sensorInputs 
     ret = []
     ret += newResponses
     for recurInput in recursiveInputs:
         outDict = dict(recurInput)
         if not 'Dir' in outDict:
             outDict['Dir'] = 1 #to the right
         if not 'StepSize' in outDict:
             outDict['StepSize'] = self['StepSize']
         outDict['Location']= Geo.addLocations(outDict['Location'],
         (outDict['StepSize']*outDict['Dir'],0))
         
         if not Geo.pointWithinBoundingBox(outDict['Location'], \
             compReg.getComponent('Screen').size):
                 outDict['Dir'] *= -1
         ret.append(outDict)
     ret += newResponses
     return (ret, ret)
Esempio n. 12
0
 def processResponse(self, sensor, recurs):
     ret = []
     for sensory in sensor:
         opsensory = dict(sensory)
         #TODO: update 19 to be a configurable variable
         self.insertVelIfMissing(opsensory)
         results = bqs.query([
             bqs.getBehaviorIdLambda('accelerate'),\
             bqs.getDirectionLambda('+'),\
             bqs.getDistLambda(opsensory['Location'], 38)
         ])
         if results:
             opsensory['XVel'] = opsensory['XVel'] + 10
         opsensory['XVel'] = min(max(-1, opsensory['XVel'] - 1), 10)
         opsensory['Location'] = Geo.addLocations((-opsensory['XVel'], 0),
                                                  opsensory['Location'])
         if opsensory['Location'][0] >= 800:  #TODO: Make this dynamic
             opsensory['Location'] = tuple([799, 25])
         ret.append(opsensory)
     return (ret, [])
Esempio n. 13
0
 def processResponse(self, sensor, recurs):
     ret = []
     for sensory in sensor:
         opsensory = dict(sensory)
         self.insertStepIfMissing(opsensory)
         #TODO: update 19 to be a configurable variable
         results = bqs.query([
             bqs.getBehaviorIdLambda(self['Id']),\
             bqs.getDifferentUIDLambda(opsensory['UniqueResponseIdentifier']),\
             bqs.getDistLambda(opsensory['Location'], 19)
         ])
         if results:
             for result in results:
                 new = opsensory['XStep'] + result['XStep']
                 if new >= 0:
                     opsensory['XStep'] = min(20, new)
                 if new < 0:
                     opsensory['XStep'] = max(-20, new)
         opsensory['Location'] = Geo.addLocations(
             (opsensory['XStep'], opsensory['YStep']),
             opsensory['Location'])
         ret.append(opsensory)
     return (ret, [])