有限状态机可以转换到先前的状态吗?
我知道 FSM 可以转换到下一个状态,甚至可以转换到当前状态,即转换到自身的状态,但是状态转换到前一个状态(状态 C 转换到状态 B)是否合法?
I know that a FSM can transition to the next state and even to the current state, i.e. a state that transitions to itself, but is it legal to have a state transition to a previous state (state C transition to state B)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,许多实用的 FSM 实际上都会这样做。考虑一种 FSM,它识别由一个或多个空格分隔的有效数字字符串。这将从“数字”状态开始,并在某个时刻转换到“空间”状态,从“空间”状态很可能转换回“数字”状态。
Yes, many practical FSMs will in fact do this. Consider an FSM that identifies valid strings of number separated by one or more spaces. This would start in the "digit" state and at some point transition to the "space" state from which it might well transition back to the "digit" state.
FSM 的“下一个状态”被定义为机器在下一个“时间片”或下一个输入到达时或其他情况下将转换到的状态。
由此定义,C 的下一个状态可以是 C 本身、B、A、D、ZORG 或机器中的任何状态。按字母顺序排列的字母并不定义前一个和后一个,仅定义 FSM 的逻辑流程。
维基百科页面上的状态机:
http://en.wikipedia.org/wiki/File:Finite_state_machine_example_with_comments.svg
The "next state" of an FSM is defined as the state the machine will transition to in the next "time slice" or when the next input arrives, or whatever.
Thus defined, the next state of C can be C itself, B, A, D, ZORG or whatever state you have in the machine. Alphabetical letters don't define what's previous and what's next, only the logical flow of the FSM.
This state machine from the Wikipedia page:
http://en.wikipedia.org/wiki/File:Finite_state_machine_example_with_comments.svg