本文整理汇总了Python中statemachine.StateMachine.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python StateMachine.__init__方法的具体用法?Python StateMachine.__init__怎么用?Python StateMachine.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statemachine.StateMachine
的用法示例。
在下文中一共展示了StateMachine.__init__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from statemachine import StateMachine [as 别名]
# 或者: from statemachine.StateMachine import __init__ [as 别名]
def __init__(self, _id=None, level=None, room=None,
speed=50, chance_to_hit=0.5, weapon_damage=5, healing=0, max_health=100,
health=100, ammo=0, morale=100):
self._id = _id if _id else str(uuid.uuid4())
self.level = level
self.room = room
self.speed = speed
self.chance_to_hit = chance_to_hit
self.weapon_damage = weapon_damage # Note: should depend on equipment
self.fight_cooldown = 1.0
self.healing = healing
self.health = health
self.ammo = ammo
self.morale = morale
self._path = deque() # the current path the entity is on
self._vision = set() # the rooms currently visible to the entity
self._timeout = 0
self._fight_timeout = 0
def log_state_change(a, b):
self.log("%s -> %s" % (a, b))
StateMachine.__init__(self, ["IDLE", "MOVING", "FIGHTING", "DEAD"],
on_state_change=log_state_change)
示例2: __init__
# 需要导入模块: from statemachine import StateMachine [as 别名]
# 或者: from statemachine.StateMachine import __init__ [as 别名]
def __init__(self, runner, ctx):
RequestQueue.__init__(self, runner)
StateMachine.__init__(self)
self.ctx = None
self.set_context(ctx) # Do early. States might depend on ctx.
self.states = {
QUIESCENT:Quiescent(self, QUIESCENT),
# Justing inverting
INVERTING_URI:InvertingUri(self, INVERTING_URI,
QUIESCENT,
FAILING),
# Requesting previous graph in order to do insert.
INVERTING_URI_4_INSERT:InvertingUri(self, INVERTING_URI_4_INSERT,
REQUESTING_URI_4_INSERT,
FAILING),
REQUESTING_URI_4_INSERT:RequestingUri(self,
REQUESTING_URI_4_INSERT,
REQUESTING_GRAPH,
FAILING),
REQUESTING_GRAPH:RequestingGraph(self, REQUESTING_GRAPH,
INSERTING_BUNDLES,
FAILING),
# Inserting
INSERTING_BUNDLES:InsertingBundles(self,
INSERTING_BUNDLES),
INSERTING_GRAPH:InsertingGraph(self, INSERTING_GRAPH,
INSERTING_URI,
FAILING),
INSERTING_URI:InsertingUri(self,INSERTING_URI,
FINISHING,
FAILING),
CANCELING:CleaningUp(self, CANCELING, QUIESCENT),
FAILING:CleaningUp(self, FAILING, QUIESCENT),
# Requesting
REQUESTING_URI:RequestingUri(self, REQUESTING_URI,
REQUESTING_BUNDLES,
FAILING),
REQUESTING_BUNDLES:RequestingBundles(self, REQUESTING_BUNDLES,
FINISHING,
FAILING),
FINISHING:CleaningUp(self, FINISHING, QUIESCENT),
# Requesting head info from freenet
REQUESTING_URI_4_HEADS:RequestingUri(self, REQUESTING_URI_4_HEADS,
REQUIRES_GRAPH_4_HEADS,
FAILING),
REQUIRES_GRAPH_4_HEADS:RequiresGraph(self, REQUIRES_GRAPH_4_HEADS,
REQUESTING_GRAPH_4_HEADS,
FINISHING),
REQUESTING_GRAPH_4_HEADS:RequestingGraph(self,
REQUESTING_GRAPH_4_HEADS,
FINISHING,
FAILING),
# Run and arbitrary StatefulRequest.
RUNNING_SINGLE_REQUEST:RunningSingleRequest(self,
RUNNING_SINGLE_REQUEST,
FINISHING,
FAILING),
# Copying.
# This doesn't verify that the graph chk(s) are fetchable.
REQUESTING_URI_4_COPY:RequestingUri(self, REQUESTING_URI_4_COPY,
INSERTING_URI,
FAILING),
}
self.current_state = self.get_state(QUIESCENT)
self.params = {}
# Must not change any state!
self.monitor_callback = lambda parent, client, msg: None
runner.add_queue(self)