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

Source Code for Module SmootLight.behaviors.RecursiveDecay

 1  from operationscore.Behavior import * 
 2  import pdb 
3 -class RecursiveDecay(Behavior):
4 """RecursiveDecay is an event to allow recursive hooks to stop recursing after a certain number 5 of iterations specified in 6 <InitialResponseCount> -- Int, number of total responses. 7 Designed to be used as part of a recursive hook. 8 """
9 - def processResponse(self, sensorInputs, recursiveInputs):
10 ret = [] 11 for response in sensorInputs: 12 if not 'ResponsesLeft' in response: 13 response['ResponsesLeft'] = self['InitialResponseCount'] 14 else: 15 response['ResponsesLeft'] -= 1 16 if response['ResponsesLeft'] > 0: 17 ret.append(response) 18 return (ret, []) #no direct ouput
19