return "%s(pc=%r, actions=%r)" % (
type(self).__name__, self.pc, self.actions)
- def Child(self, actions, params, rank, repeat=1):
+ def Child(self, action, params, rank, repeat=1):
+ actions, params = action(params, rank)
return type(self)(self, actions, params, rank, repeat)
def vanish(self):
def __call__(self, owner, action, params, rank, created):
repeat = self.times(params, rank)
- actions, params = self.action(params, rank)
- child = action.Child(actions, params, rank, repeat)
+ child = action.Child(self.action, params, rank, repeat)
owner.replace(action, child)
child.step(owner, created)
return True
branch = self.else_
if branch:
- actions, params = branch(params, rank)
- child = action.Child(actions, params, rank)
+ child = action.Child(branch, params, rank)
owner.replace(action, child)
child.step(owner, created)
return True
+
+ def __repr__(self):
+ if self.else_:
+ return "%s(%r, then=%r, else_=%r)" % (
+ type(self).__name__, self.cond, self.then, self.else_)
+ else:
+ return "%s(%r, then=%r)" % (
+ type(self).__name__, self.cond, self.then)
class Accel(object):
"""Accelerate over some time."""