Package SmootLight :: Package behaviors :: Module Square
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.behaviors.Square

 1  from operationscore.Behavior import * 
2 -class Square(Behavior):
3 """Square is a simple behavior that makes a square with side lengths Width*2 around locations in 4 the sensor input. Specify: 5 <Width> -- the sidelength/2 6 """ 7
8 - def processResponse(self, sensorInputs, recursiveInputs):
9 for sensory in sensorInputs:#TODO: consider replicating the dict 10 sensory['CenterLoc'] = list(sensory['Location']) 11 xLoc = sensory['Location'][0] 12 yLoc = sensory['Location'][1] 13 width = self['Width'] 14 #sensory['Location'] = 'True' 15 sensory['Location'] =\ 16 '{x}<'+str(xLoc+width)+',{x}>'+str(xLoc-width)+\ 17 ',{y}<'+str(yLoc+width)+',{y}>'+str(yLoc-width) 18 return (sensorInputs, recursiveInputs)
19
20 - def setLastOutput(self, output):
21 coutput = Behavior.deepCopyPacket(output) 22 for data in coutput: 23 data['Location'] = data['CenterLoc'] 24 return coutput
25