aboutsummaryrefslogtreecommitdiff
path: root/behaviors
diff options
context:
space:
mode:
authorGravatar Russell Cohen <rcoh@mit.edu>2010-11-25 21:44:00 -0500
committerGravatar Russell Cohen <rcoh@mit.edu>2010-11-25 21:44:00 -0500
commit5783d6336f014c05e0e46d7bc35533e70b280582 (patch)
treeb4e0b0b2787b8fe464baadbd375ad6dc6c1dbf76 /behaviors
parentb042647b68abdc82490ca6e059993b8eba28904c (diff)
Added BehaviorChain to support chains of behaviors. Added FollowMouse
parameter to PygameInput to support following of mice. Added component registry to Util which allows any component to access any other component. Some changes to the structure of LightInstallation.
Diffstat (limited to 'behaviors')
-rw-r--r--behaviors/BehaviorChain.py10
-rw-r--r--behaviors/ColorChangerBehavior.py12
-rw-r--r--behaviors/DecayBehavior.py15
3 files changed, 37 insertions, 0 deletions
diff --git a/behaviors/BehaviorChain.py b/behaviors/BehaviorChain.py
new file mode 100644
index 0000000..15f7d74
--- /dev/null
+++ b/behaviors/BehaviorChain.py
@@ -0,0 +1,10 @@
+from operationscore.Behavior import *
+import Util
+import pdb
+class BehaviorChain(Behavior):
+ def processResponse(self, sensorInputs, recursiveInputs):
+ response = sensorInputs
+ for behaviorId in self['ChainedBehaviors']:
+ behavior = Util.getComponentById(behaviorId)
+ response = behavior.immediateProcessInput(response)
+ return response
diff --git a/behaviors/ColorChangerBehavior.py b/behaviors/ColorChangerBehavior.py
new file mode 100644
index 0000000..8ecc5f2
--- /dev/null
+++ b/behaviors/ColorChangerBehavior.py
@@ -0,0 +1,12 @@
+from operationscore.Behavior import *
+import Util
+import pdb
+class ColorChangerBehavior(Behavior):
+ def processResponse(self, sensorInputs, recursiveInputs):
+ ret = []
+ for sensory in sensorInputs:
+ newDict = dict(sensory) #don't run into shallow copy issues
+ #TODO: support for PixelEvents
+ newDict['Color'] = Util.randomColor()
+ ret.append(newDict)
+ return ret
diff --git a/behaviors/DecayBehavior.py b/behaviors/DecayBehavior.py
new file mode 100644
index 0000000..f9efa3b
--- /dev/null
+++ b/behaviors/DecayBehavior.py
@@ -0,0 +1,15 @@
+from operationscore.Behavior import *
+from pixelevents.DecayEvent import *
+import Util
+import pdb
+class DecayBehavior(Behavior):
+ def processResponse(self, sensorInputs, recursiveInputs):
+ ret = []
+ #TODO: move into params
+ for sensory in sensorInputs:
+ outDict = {}
+ outDict[Util.location] = sensory[Util.location]
+ outDict['PixelEvent'] = \
+ DecayEvent.generate('Proportional',100, sensory['Color'])
+ ret.append(outDict)
+ return ret