本文介绍了什么样的问题是状态机好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么样的​​规划问题是状态机最适合的呢?

What kind of programming problems are state machines most suited for?

我已阅读有关使用状态机正在实施分析程序,但想了解的尖叫实现为一个状态机的问题。

I have read about parsers being implemented using state machines, but would like to find out about problems that scream out to be implemented as a state machine.

推荐答案

最简单的答案很可能是,它们都适用于几乎任何问题。不要忘了,电脑本身也是一个状态机。

The easiest answer is probably that they are suited for practically any problem. Don't forget that a computer itself is also a state machine.

不管是,状态机通常用于问题在有输入的一些流,并且需要在一个给定的时刻进行取决于看出,流在该点中的最后一个元件的活性。

Regardless of that, state machines are typically used for problems where there is some stream of input and the activity that needs to be done at a given moment depends the last elements seen in that stream at that point.

此流的输入的例子:在分析的情况下,一些文本文件,字符串经常EX pressions,如玩家进入房间游戏活动AI等。

Examples of this stream of input: some text file in the case of parsing, a string for regular expressions, events such as player entered room for game AI, etc.

活动的例子:准备读一些(后另一个号码后跟一个 + 已经出现在输入一个解析器计算器),转身(之后玩家走近,然后打了个喷嚏),执行跳踢(后玩家pressed左,左,右,上,向上)。

Examples of activities: be ready to read a number (after another number followed by a + have appear in the input in a parser for a calculator), turn around (after player approached and then sneezed), perform jumping kick (after player pressed left, left, right, up, up).

这篇关于什么样的问题是状态机好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 12:39
查看更多