aboutsummaryrefslogtreecommitdiff
path: root/util/BehaviorQuerySystem.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-16 15:26:29 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-16 15:26:29 -0500
commit3c405fa182b1e524f5724e65266667d8f65dc179 (patch)
tree2e1320d152f4ae8579eb8f651be0af12da25c6cb /util/BehaviorQuerySystem.py
parentd8ba03006e2ea1400e80caded738e79c186e8de3 (diff)
parentf34e1c732036553e4a68534dfc1b24a13ccd33ce (diff)
Merge branch 'master' into behavior-factory
Diffstat (limited to 'util/BehaviorQuerySystem.py')
-rw-r--r--util/BehaviorQuerySystem.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/util/BehaviorQuerySystem.py b/util/BehaviorQuerySystem.py
index 643b95c..688eecb 100644
--- a/util/BehaviorQuerySystem.py
+++ b/util/BehaviorQuerySystem.py
@@ -7,6 +7,7 @@ def initBQS():
initialized = True
def addBehavior(behavior):
+ """Add a behavior to the behavior registry."""
behaviorList.append(behavior)
def query(predicateList):
@@ -36,4 +37,11 @@ def query(predicateList):
ret.append(output)
return ret
+def getDistLambda(loc, maxDist):
+ """Returns a lambda function that checks if for behaviors within maxDist of loc. Can be passed
+ in as an arg to query."""
+ return lambda args:geo.dist(args['Location'], loc) <= maxDist
+def getBehaviorsNear(loc, maxdist):
+ """A premade method to do the common task of finding behavior near a location."""
+ return query(getDistLambda(loc, maxDist))