Package SmootLight :: Package behaviors :: Module RandomWalk
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.behaviors.RandomWalk

 1  from operationscore.Behavior import * 
 2  import util.ComponentRegistry as compReg 
 3  import util.Geo as Geo 
 4  import util.Strings as Strings 
 5  import random 
 6  import pdb 
7 -class RandomWalk(Behavior):
8 """Behavior to move the curent location by a random distance specified by 9 <StepSize> -- StepSize in units/response""" 10
11 - def processResponse(self, sensors, recursives):
12 ret = [] 13 s = self['StepSize'] 14 for sensory in sensors: 15 step = [random.randint(-s,s), random.randint(-s,s)] 16 outdict = dict(sensory) 17 outdict[Strings.LOCATION] = Geo.addLocations(step, outdict[Strings.LOCATION]) 18 ret.append(outdict) 19 return (ret,recursives)
20