diff options
-rw-r--r-- | behaviors/RandomWalk.py | 2 | ||||
-rw-r--r-- | behaviors/RestrictLocation.py | 12 | ||||
-rw-r--r-- | util/ComponentRegistry.py | 3 |
3 files changed, 16 insertions, 1 deletions
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) |