diff options
author | Russell Cohen <rcoh@mit.edu> | 2011-01-12 11:58:00 -0500 |
---|---|---|
committer | Russell Cohen <rcoh@mit.edu> | 2011-01-12 11:58:00 -0500 |
commit | 907780f6b298bfa259ace94d07ca137099067e67 (patch) | |
tree | a12e1f555c27982b39a49c89383544773ba08039 /behaviors | |
parent | c7fc6c2725231eb1427f0edf00d3219409b3d55b (diff) |
Added ResponseMover to facilitate spawn and run responses. Modified
simplemapper to fix a bug with null responses.
Diffstat (limited to 'behaviors')
-rw-r--r-- | behaviors/PixelDecay.xml | 9 | ||||
-rw-r--r-- | behaviors/RandomWalk.py | 13 | ||||
-rw-r--r-- | behaviors/ResponseMover.py | 15 |
3 files changed, 28 insertions, 9 deletions
diff --git a/behaviors/PixelDecay.xml b/behaviors/PixelDecay.xml index bfe84ca..c19a1a8 100644 --- a/behaviors/PixelDecay.xml +++ b/behaviors/PixelDecay.xml @@ -1,12 +1,3 @@ -<!--<Behavior> - <Class>behaviors.DecayBehavior</Class> - <Args> - <DecayType>Exponential</DecayType> - <Coefficient>.01</Coefficient> - <z-index>0</z-index> - <RenderToScreen>False</RenderToScreen> - </Args> -</Behavior>--> <Behavior> <Class>behaviors.AddPixelEvent</Class> <Args> diff --git a/behaviors/RandomWalk.py b/behaviors/RandomWalk.py index 8254430..5a32792 100644 --- a/behaviors/RandomWalk.py +++ b/behaviors/RandomWalk.py @@ -1,5 +1,18 @@ from operationscore.Behavior import * import util.ComponentRegistry as compReg +import util.Geo as Geo +import util.Strings as Strings +import random class RandomWalk(Behavior): def processResponse(self, sensors, recursives): + ret = [] + for sensory in sensors: + s = self['StepSize'] + 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) + + diff --git a/behaviors/ResponseMover.py b/behaviors/ResponseMover.py new file mode 100644 index 0000000..e1faccb --- /dev/null +++ b/behaviors/ResponseMover.py @@ -0,0 +1,15 @@ +import pdb +from operationscore.Behavior import * +import util.ComponentRegistry as compReg +#ResponseMover is a scaffold for behaviors that spawn 'walkers' which act autonomously on input. +#Add a recursive hook to control the movement. +class ResponseMover(Behavior): + def processResponse(self, sensorInputs, recursiveInputs): + newResponses = sensorInputs + ret = [] + for recurInput in recursiveInputs: + outDict = dict(recurInput) + ret.append(outDict) + ret += newResponses + return (ret, ret) + |