当前位置: 首页>>代码示例>>Python>>正文


Python StateMachine.__init__方法代码示例

本文整理汇总了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)
开发者ID:DiscoMountain,项目名称:Controlroom-Blues,代码行数:30,代码来源:entity.py

示例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)
开发者ID:ArneBab,项目名称:infocalypse,代码行数:88,代码来源:updatesm.py


注:本文中的statemachine.StateMachine.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。