1 from operationscore.Behavior import *
2 import util.ComponentRegistry as compReg
3 import util.Geo as Geo
4 import pdb
6 """RunningBehavior is a straightforward behavior that makes a Location run back and forth across
7 a screen. Specify:
8 <StepSize> -- the length of movment in units when the response moves.
9 """
10
12 newResponses = sensorInputs
13 ret = []
14 ret += newResponses
15 for recurInput in recursiveInputs:
16 outDict = dict(recurInput)
17 if not 'Dir' in outDict:
18 outDict['Dir'] = 1
19 if not 'StepSize' in outDict:
20 outDict['StepSize'] = self['StepSize']
21 outDict['Location']= Geo.addLocations(outDict['Location'],
22 (outDict['StepSize']*outDict['Dir'],0))
23
24 if not Geo.pointWithinBoundingBox(outDict['Location'], \
25 compReg.getComponent('Screen').getSize()):
26 outDict['Dir'] *= -1
27 ret.append(outDict)
28 ret += newResponses
29 return (ret, ret)
30