aboutsummaryrefslogtreecommitdiff
path: root/behaviors/RunningBehavior.py
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2010-11-29 00:00:26 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2010-11-29 00:00:26 -0500
commitcf1f2224b3625b01a6aa7db221403849b308b3bc (patch)
tree9ad55077f45efc7a8434688332ee281a28a1cae7 /behaviors/RunningBehavior.py
parent9c9babfa7032b443138c4b457aabaf79fad385b3 (diff)
Making recursive behaviors work. Some bugs existed before. Adding running
behavior which makes a signal bounce back and forth.
Diffstat (limited to 'behaviors/RunningBehavior.py')
-rw-r--r--behaviors/RunningBehavior.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/behaviors/RunningBehavior.py b/behaviors/RunningBehavior.py
new file mode 100644
index 0000000..255ce69
--- /dev/null
+++ b/behaviors/RunningBehavior.py
@@ -0,0 +1,21 @@
+from operationscore.Behavior import *
+import pdb
+import Util
+class RunningBehavior(Behavior):
+ def processResponse(self, sensorInputs, recursiveInputs):
+ newResponses = sensorInputs
+ ret = []
+ ret += newResponses
+ for recurInput in recursiveInputs:
+ outDict = dict(recurInput)
+ if not 'Dir' in outDict:
+ outDict['Dir'] = 1 #to the right
+ outDict['Location']= Util.addLocations(outDict['Location'],
+ (self['StepSize']*outDict['Dir'],0))
+ if not Util.pointWithinBoundingBox(outDict['Location'], \
+ Util.getScreen().getSize()):
+ outDict['Dir'] *= -1
+ ret.append(outDict)
+ ret += newResponses
+ return (ret, ret)
+