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