Esempio n. 1
0
 def behaviorInit(self):
     action = self['Action']
     modifyParamArgs = {
         'ParamType': 'Sensor',
         'ParamName': self['ParamName'],
         'ParamOp': self['Action']
     }
     self.locBounds = self['LocationRestriction']
     self.paramModifier = ModifyParam(modifyParamArgs)
     xmin, ymin, xmax, ymax = compReg.getComponent('Screen').getSize()
     replacementDict = {
         '{x}': 'l[0]',
         '{y}': 'l[1]',
         '{xmin}': str(xmin),
         '{xmax}': str(xmax),
         '{ymin}': str(ymin),
         '{ymax}': str(ymax)
     }
     if isinstance(self.locBounds, str):
         for key in replacementDict:
             self.locBounds = self.locBounds.replace(
                 key, replacementDict[key])
         self.locEval = eval('lambda l:' + self.locBounds)
     elif isinstance(self.locBounds, tuple):
         if len(self.locBounds) != 4:
             raise Exception('Must be in form (xmin,yin,xmax,ymax)')
         else:
             self.locEval = lambda l:Geo.pointWithinBoundingBox(l,\
                     self.LocBounds)
Esempio n. 2
0
 def recalc(self):
     self.locBounds = self['LocationRestriction']
     xmin,ymin,xmax,ymax = compReg.getComponent('Screen').size
     replacementDict = {'{x}':'l[0]','{y}':'l[1]', '{xmin}':str(xmin), '{xmax}':str(xmax),
                        '{ymin}':str(ymin),'{ymax}':str(ymax)}
     if isinstance(self.locBounds, str) or isinstance(self.locBounds, unicode):
         for key in replacementDict:
             self.locBounds = self.locBounds.replace(key, replacementDict[key])
         self.locEval = eval('lambda l:'+self.locBounds)
     elif isinstance(self.locBounds, tuple):
         if len(self.locBounds) != 4:
             raise Exception('Must be in form (xmin,yin,xmax,ymax)')
         else:
             self.locEval = lambda l:Geo.pointWithinBoundingBox(l,\
                     self.LocBounds)
Esempio n. 3
0
 def behaviorInit(self):
     action = self['Action']
     modifyParamArgs = {'ParamType': 'Sensor',
             'ParamName':self['ParamName'],'ParamOp':self['Action']} 
     self.locBounds = self['LocationRestriction']
     self.paramModifier = ModifyParam(modifyParamArgs) 
     if isinstance(self.locBounds, str):
         self.locBounds = self.locBounds.replace('{x}', 'l[0]')
         self.locBounds = self.locBounds.replace('{y}', 'l[1]')
         self.locEval = eval('lambda l:'+self.locBounds)
     elif isinstance(self.locBounds, tuple):
         if len(self.locBounds) != 4:
             raise Exception('Must be in form (xmin,yin,xmax,ymax)')
         else:
             self.locEval = lambda l:Geo.pointWithinBoundingBox(l,\
                     self.LocBounds)
Esempio n. 4
0
 def behaviorInit(self):
     modifyParamArgs = {'ParamType': 'Sensor',
             'ParamName':self['ParamName'],'ParamOp':self['Action']} 
     self.locBounds = self['LocationRestriction']
     self.paramModifier = ModifyParam(modifyParamArgs) 
     xmin,ymin,xmax,ymax = compReg.getComponent('Screen').size
     replacementDict = {'{x}':'l[0]','{y}':'l[1]', '{xmin}':str(xmin), '{xmax}':str(xmax),
                        '{ymin}':str(ymin),'{ymax}':str(ymax)}
     if isinstance(self.locBounds, str):
         for key in replacementDict:
             self.locBounds = self.locBounds.replace(key, replacementDict[key])
         self.locEval = eval('lambda l:'+self.locBounds)
     elif isinstance(self.locBounds, tuple):
         if len(self.locBounds) != 4:
             raise Exception('Must be in form (xmin,yin,xmax,ymax)')
         else:
             self.locEval = lambda l:Geo.pointWithinBoundingBox(l,\
                     self.LocBounds)
Esempio n. 5
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. 6
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. 7
0
 def recalc(self):
     self.locBounds = self['LocationRestriction']
     xmin, ymin, xmax, ymax = compReg.getComponent('Screen').size
     replacementDict = {
         '{x}': 'l[0]',
         '{y}': 'l[1]',
         '{xmin}': str(xmin),
         '{xmax}': str(xmax),
         '{ymin}': str(ymin),
         '{ymax}': str(ymax)
     }
     if isinstance(self.locBounds, str) or isinstance(
             self.locBounds, unicode):
         for key in replacementDict:
             self.locBounds = self.locBounds.replace(
                 key, replacementDict[key])
         self.locEval = eval('lambda l:' + self.locBounds)
     elif isinstance(self.locBounds, tuple):
         if len(self.locBounds) != 4:
             raise Exception('Must be in form (xmin,yin,xmax,ymax)')
         else:
             self.locEval = lambda l:Geo.pointWithinBoundingBox(l,\
                     self.LocBounds)