aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-12 20:39:58 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-12 20:39:58 -0500
commitc8316a35a1eb292f09db8b7ff36dd33b43dfe8b6 (patch)
tree4abd076114d333440c239af950f630cbbbcf329b /util
parenta239c7accdc634459d2db014b8d8b6d5b78bab1b (diff)
Added an override of setLastOutput to square.py. Added some pre-built queries into the BQS.
Modified the default behavior or setLastOutput to make a deep copy of ouput to prevent accidental interference.
Diffstat (limited to 'util')
-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))