if self.__value is not None:
return self.__value
rand = random.random()
- variables = dict(rand=rand, rank=rank, params=params)
+ variables = { 'rand': rand, 'rank': rank, 'params': params }
return eval(self.__expr, variables)
def __repr__(self):
self.actions = []
if rank is None:
rank = parent.rank if parent else 0.5
- for action, params in actions:
- # New bullets reset the parent hierarchy.
- self.actions.append(Action(self, None, action, params, rank))
+ # New bullets reset the parent hierarchy.
+ self.actions = [Action(self, None, action, params, rank)
+ for action, params in actions]
def __repr__(self):
return ("%s(%r, %r, accel=%r, direction=%r, speed=%r, "
self.params.append(NumberDef(subelem.text))
def __call__(self, params, rank):
- new_params = [param(params, rank) for param in self.params]
- while len(new_params) < len(params):
- new_params.append(params[len(new_params)])
- return new_params
+ return [param(params, rank) for param in self.params]
def __repr__(self):
return "%s(%r)" % (type(self).__name__, self.params)
self.actions.append(ActionRef(doc, subelem))
def __call__(self, params, rank):
- actions = []
- for action in self.actions:
- actions.append(action(params, rank))
+ actions = [action(params, rank) for action in self.actions]
return (
self.direction and self.direction(params, rank),
self.speed and self.speed(params, rank),