Package SmootLight :: Package behaviors :: Module ColorChangerBehavior
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.behaviors.ColorChangerBehavior

 1  from operationscore.Behavior import * 
 2  import util.ColorOps as color 
 3  import pdb 
4 -class ColorChangerBehavior(Behavior):
5 """ColorChangerBehavior is a behavior for adding colors to responses. If given no arguments, it 6 will generate a random color. If it is given a list of colors [as below] it will pick randomly 7 from them. 8 9 <ColorList> 10 <Color>(255,0,0)</Color> 11 <Color>(30,79,200)</Color> 12 </ColorList> 13 14 ColorList also supports specification of a single color.""" 15
16 - def processResponse(self, sensorInputs, recursiveInputs):
17 ret = [] 18 for sensory in sensorInputs: 19 newDict = dict(sensory) 20 if self['ColorList'] != None: 21 if isinstance(self['ColorList'], list): 22 newDict['Color'] = color.chooseRandomColor(self['ColorList']) #Pick randomly 23 else: 24 newDict['Color'] = self['ColorList'] #Unless there is only one 25 else: 26 newDict['Color'] = color.randomColor() 27 ret.append(newDict) 28 return (ret, [])
29