diff options
Diffstat (limited to 'behaviors')
-rw-r--r-- | behaviors/BehaviorChain.py | 5 | ||||
-rw-r--r-- | behaviors/ColorChangerBehavior.py | 7 | ||||
-rw-r--r-- | behaviors/DecayBehavior.py | 3 | ||||
-rw-r--r-- | behaviors/EchoBehavior.py | 3 | ||||
-rw-r--r-- | behaviors/RunningBehavior.py | 8 |
5 files changed, 15 insertions, 11 deletions
diff --git a/behaviors/BehaviorChain.py b/behaviors/BehaviorChain.py index fe50573..65f5c9d 100644 --- a/behaviors/BehaviorChain.py +++ b/behaviors/BehaviorChain.py @@ -1,4 +1,5 @@ from operationscore.Behavior import * +import util.ComponentRegistry as compReg import Util import pdb class BehaviorChain(Behavior): @@ -10,7 +11,7 @@ class BehaviorChain(Behavior): def processResponse(self, sensorInputs, recursiveInputs): response = sensorInputs for behaviorId in self['ChainedBehaviors']: - behavior = Util.getComponentById(behaviorId) + behavior = compReg.getComponent(behaviorId) if behaviorId in self.feedback: recurrence = self.feedback[behaviorId] else: @@ -19,7 +20,7 @@ class BehaviorChain(Behavior): recurrence) if behaviorId in self.hooks: #process recursive hook if there is one - hookBehavior = Util.getComponentById(self.hooks[behaviorId]) + hookBehavior = compReg.getComponent(self.hooks[behaviorId]) #we feed its recurrence in as input to the behavior. (recurrence, hookRecurrence) = \ hookBehavior.immediateProcessInput(recurrence, \ diff --git a/behaviors/ColorChangerBehavior.py b/behaviors/ColorChangerBehavior.py index a3b1739..e1827eb 100644 --- a/behaviors/ColorChangerBehavior.py +++ b/behaviors/ColorChangerBehavior.py @@ -1,5 +1,5 @@ from operationscore.Behavior import * -import Util +import util.ColorOps as color import pdb class ColorChangerBehavior(Behavior): def processResponse(self, sensorInputs, recursiveInputs): @@ -7,9 +7,8 @@ class ColorChangerBehavior(Behavior): for sensory in sensorInputs: newDict = dict(sensory) #don't run into shallow copy issues if self['ColorList'] != None: - newDict['Color'] = Util.chooseRandomColor(self['ColorList']) #TODO: this doesn't work. + newDict['Color'] = color.chooseRandomColor(self['ColorList']) #TODO: this doesn't work. else: - newDict['Color'] = Util.randomColor() -#newDict['Color'] = (255,0,0) + newDict['Color'] = color.randomColor() ret.append(newDict) return (ret, recursiveInputs) diff --git a/behaviors/DecayBehavior.py b/behaviors/DecayBehavior.py index edc833d..56e1686 100644 --- a/behaviors/DecayBehavior.py +++ b/behaviors/DecayBehavior.py @@ -1,5 +1,6 @@ from operationscore.Behavior import * from pixelevents.DecayEvent import * +import util.Strings as Strings import Util import pdb class DecayBehavior(Behavior): @@ -7,7 +8,7 @@ class DecayBehavior(Behavior): ret = [] for sensory in sensorInputs: outDict = {} - outDict[Util.location] = sensory[Util.location] + outDict[Strings.LOCATION] = sensory[Strings.LOCATION] outDict['PixelEvent'] = \ DecayEvent.generate(self['DecayType'],self['Coefficient'], sensory['Color']) ret.append(outDict) diff --git a/behaviors/EchoBehavior.py b/behaviors/EchoBehavior.py index a11558a..002f8fb 100644 --- a/behaviors/EchoBehavior.py +++ b/behaviors/EchoBehavior.py @@ -1,4 +1,5 @@ from operationscore.Behavior import * +import util.Strings as Strings import Util import pdb class EchoBehavior(Behavior): @@ -6,7 +7,7 @@ class EchoBehavior(Behavior): ret = [] for sensory in sensorInputs: outDict = {} - outDict[Util.location] = sensory[Util.location] + outDict[Strings.LOCATION] = sensory[Strings.LOCATION] outDict['Color'] = (255,0,0) ret.append(outDict) return ret diff --git a/behaviors/RunningBehavior.py b/behaviors/RunningBehavior.py index 3d82d29..1969162 100644 --- a/behaviors/RunningBehavior.py +++ b/behaviors/RunningBehavior.py @@ -1,4 +1,6 @@ from operationscore.Behavior import * +import util.ComponentRegistry as compReg +import util.Geo as Geo import pdb import Util class RunningBehavior(Behavior): @@ -12,10 +14,10 @@ class RunningBehavior(Behavior): outDict['Dir'] = 1 #to the right if not 'StepSize' in outDict: outDict['StepSize'] = self['StepSize'] - outDict['Location']= Util.addLocations(outDict['Location'], + outDict['Location']= Geo.addLocations(outDict['Location'], (outDict['StepSize']*outDict['Dir'],0)) - if not Util.pointWithinBoundingBox(outDict['Location'], \ - Util.getScreen().getSize()): + if not Geo.pointWithinBoundingBox(outDict['Location'], \ + compReg.getComponent('Screen').getSize()): outDict['Dir'] *= -1 ret.append(outDict) ret += newResponses |