當前位置: 首頁>>代碼示例>>Python>>正文


Python TransitionTable.addTerminalState方法代碼示例

本文整理匯總了Python中machinist.TransitionTable.addTerminalState方法的典型用法代碼示例。如果您正苦於以下問題:Python TransitionTable.addTerminalState方法的具體用法?Python TransitionTable.addTerminalState怎麽用?Python TransitionTable.addTerminalState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在machinist.TransitionTable的用法示例。


在下文中一共展示了TransitionTable.addTerminalState方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_addTerminalState

# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
 def test_addTerminalState(self):
     """
     L{TransitionTable.addTerminalState} returns a L{TransitionTable} that
     includes the given state in its table with no transitions defined.
     """
     table = TransitionTable()
     more = table.addTerminalState("foo")
     self.assertEqual({"foo": {}}, more.table)
開發者ID:ClusterHQ,項目名稱:machinist,代碼行數:10,代碼來源:test_fsm.py

示例2: test_nextStateNotMissingIfInitial

# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
    def test_nextStateNotMissingIfInitial(self):
        """
        L{MissingTransitionNextState} is not raised if a value defined by
        C{state} appears nowhere in C{transitions} as a next state but is given
        as C{initial}.
        """
        transitions = TransitionTable()
        transitions = transitions.addTransition(
            MoreState.amber, Input.apple, [Output.aardvark], MoreState.amber)
        transitions = transitions.addTerminalState(MoreState.blue)

        constructFiniteStateMachine(
            Input, Output, MoreState, transitions,
            MoreState.blue, [], {}, NULL_WORLD)
開發者ID:ClusterHQ,項目名稱:machinist,代碼行數:16,代碼來源:test_fsm.py

示例3: test_missingTransitionNextState

# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
    def test_missingTransitionNextState(self):
        """
        L{MissingTransitionNextState} is raised if any of the values defined by
        C{state} appears nowhere in C{transitions} as a next state.
        """
        transitions = TransitionTable()
        transitions = transitions.addTransition(
            MoreState.amber, Input.apple, [Output.aardvark], MoreState.amber)
        transitions = transitions.addTerminalState(MoreState.blue)

        exc = self.assertRaises(
            MissingTransitionNextState,
            constructFiniteStateMachine,
            Input, Output, MoreState, transitions,
            MoreState.amber, [], {}, NULL_WORLD)
        self.assertEqual(({MoreState.blue},), exc.args)
開發者ID:ClusterHQ,項目名稱:machinist,代碼行數:18,代碼來源:test_fsm.py

示例4: IFood

# 需要導入模塊: from machinist import TransitionTable [as 別名]
# 或者: from machinist.TransitionTable import addTerminalState [as 別名]
class IFood(Interface):
    radius = Attribute("The radius of the food (all food is spherical)")



@implementer(IFood)
class Gravenstein(trivialInput(Input.apple)):
    # Conveniently, apples are approximately spherical.
    radius = 3



TRANSITIONS = TransitionTable()
TRANSITIONS = TRANSITIONS.addTransition(
    MoreState.amber, Input.apple, [Output.aardvark], MoreState.blue)
TRANSITIONS = TRANSITIONS.addTerminalState(MoreState.blue)


class FiniteStateMachineTests(TestCase):
    """
    Tests for the L{IFiniteStateMachine} provider returned by
    L{constructFiniteStateMachine}.
    """
    def setUp(self):
        self.animals = []
        self.initial = MoreState.amber

        self.world = AnimalWorld(self.animals)
        self.fsm = constructFiniteStateMachine(
            Input, Output, MoreState, TRANSITIONS, self.initial,
            [Gravenstein], {Output.aardvark: IFood},
開發者ID:ClusterHQ,項目名稱:machinist,代碼行數:33,代碼來源:test_fsm.py


注:本文中的machinist.TransitionTable.addTerminalState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。