aboutsummaryrefslogtreecommitdiff
path: root/behaviors/ColorChangerBehavior.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-01 23:14:12 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-01 23:14:12 -0500
commit5a97e7548b0ec44f0d61a724903748197e69df7c (patch)
tree7bb6b8ea7e488949eeb16ae18b0ad2230f1f7c9b /behaviors/ColorChangerBehavior.py
parent082e4b0c53123dd377da148541f7d98516716862 (diff)
parent482a94fd48627153b923931d6ff21ebf57fad6f7 (diff)
Merge branch 'osc' of github.com:rcoh/SmootLight into osc
Diffstat (limited to 'behaviors/ColorChangerBehavior.py')
-rw-r--r--behaviors/ColorChangerBehavior.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/behaviors/ColorChangerBehavior.py b/behaviors/ColorChangerBehavior.py
index 2a8d974..e2f8bd3 100644
--- a/behaviors/ColorChangerBehavior.py
+++ b/behaviors/ColorChangerBehavior.py
@@ -2,12 +2,26 @@ from operationscore.Behavior import *
import util.ColorOps as color
import pdb
class ColorChangerBehavior(Behavior):
+ """ColorChangerBehavior is a behavior for adding colors to responses. If given no arguments, it
+ will generate a random color. If it is given a list of colors [as below] it will pick randomly
+ from them.
+
+ <ColorList>
+ <Color>(255,0,0)</Color>
+ <Color>(30,79,200)</Color>
+ </ColorList>
+
+ ColorList also supports specification of a single color."""
+
def processResponse(self, sensorInputs, recursiveInputs):
ret = []
for sensory in sensorInputs:
- newDict = dict(sensory) #don't run into shallow copy issues
+ newDict = dict(sensory)
if self['ColorList'] != None:
- newDict['Color'] = color.chooseRandomColor(self['ColorList']) #TODO: this doesn't work.
+ if isinstance(self['ColorList'], list):
+ newDict['Color'] = color.chooseRandomColor(self['ColorList']) #Pick randomly
+ else:
+ newDict['Color'] = self['ColorList'] #Unless there is only one
else:
newDict['Color'] = color.randomColor()
ret.append(newDict)