From c8316a35a1eb292f09db8b7ff36dd33b43dfe8b6 Mon Sep 17 00:00:00 2001 From: rcoh Date: Sat, 12 Feb 2011 20:39:58 -0500 Subject: 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. --- util/BehaviorQuerySystem.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util/BehaviorQuerySystem.py') 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)) -- cgit v1.2.3