From 0af38d1882291523d0d290a638e88be793f27678 Mon Sep 17 00:00:00 2001 From: rcoh Date: Sun, 16 Jan 2011 21:09:26 -0500 Subject: a couple more behavior additions --- behaviors/RandomWalk.py | 2 +- behaviors/RestrictLocation.py | 12 ++++++++++++ util/ComponentRegistry.py | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 behaviors/RestrictLocation.py diff --git a/behaviors/RandomWalk.py b/behaviors/RandomWalk.py index 5a32792..dfe6716 100644 --- a/behaviors/RandomWalk.py +++ b/behaviors/RandomWalk.py @@ -6,8 +6,8 @@ import random class RandomWalk(Behavior): def processResponse(self, sensors, recursives): ret = [] + s = self['StepSize'] 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]) diff --git a/behaviors/RestrictLocation.py b/behaviors/RestrictLocation.py new file mode 100644 index 0000000..649500f --- /dev/null +++ b/behaviors/RestrictLocation.py @@ -0,0 +1,12 @@ +from operationscore.Behavior import * +import util.ComponentRegistry as compReg +import util.Geo as Geo +import util.Strings as Strings +import random +class RestrictLocation(Behavior): + def behaviorInit(self): + action = self['Action'] + modifyParamArgs = {'ParamType': 'Sensor', + 'ParamName':self['ParamName'],'ParamOp':self['Action']} + + def processInput( diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py index 43c4795..776cd17 100644 --- a/util/ComponentRegistry.py +++ b/util/ComponentRegistry.py @@ -31,6 +31,9 @@ def registerComponent(component, cid=None): globals()['Registry'][cid] = component return cid +def verifyUniqueId(cid): + return not cid in globals()['Registry'] + def removeComponent(cid): globals()['Registry'].pop(cid) -- cgit v1.2.3