diff options
Diffstat (limited to 'behaviors')
-rw-r--r-- | behaviors/BehaviorChain.py | 10 | ||||
-rw-r--r-- | behaviors/ColorChangerBehavior.py | 12 | ||||
-rw-r--r-- | behaviors/DecayBehavior.py | 15 |
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 |