From 907780f6b298bfa259ace94d07ca137099067e67 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Wed, 12 Jan 2011 11:58:00 -0500 Subject: Added ResponseMover to facilitate spawn and run responses. Modified simplemapper to fix a bug with null responses. --- behaviors/PixelDecay.xml | 9 --------- behaviors/RandomWalk.py | 13 +++++++++++++ behaviors/ResponseMover.py | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 behaviors/ResponseMover.py (limited to 'behaviors') 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 @@ - behaviors.AddPixelEvent 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) + -- cgit v1.2.3