aboutsummaryrefslogtreecommitdiff
path: root/behaviors/RandomWalk.py
blob: c9049af0d82ac80dc691a7a6c158add381f459d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from operationscore.Behavior import *
import util.ComponentRegistry as compReg
import util.Geo as Geo
import util.Strings as Strings
import random
import pdb
class RandomWalk(Behavior):
    """Behavior to move the curent location by a random distance specified by 
    <StepSize> -- StepSize in units/response"""

    def processResponse(self, sensors, recursives):
        ret = []
        s = self['StepSize']
        for sensory in sensors:
            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)