aboutsummaryrefslogtreecommitdiff
path: root/inputs/RandomLocs.py
blob: f4182cf8fa64bd212ede523d2ac9088fcb540d7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import util.TimeOps as clock
import random
import util.Geo as Geo
import util.Strings as Strings
from operationscore.Input import *
class RandomLocs(Input):
    """RandomLocs is an Input that generates RandomLocations at a preset but randomly changing time interval.  Just a
    prototype, some assembly required."""

    def inputInit(self):
        self['LastEvent'] = clock.time()
    def sensingLoop(self): #TODO: move to params
        currentTime = clock.time()
        if currentTime - self['LastEvent'] > 200+500*random.random():
            self.respond({Strings.LOCATION: Geo.randomLoc((200,200))})
            self['LastEvent'] = currentTime