Git Product home page Git Product logo

myfsm's Introduction

什么是状态机

有限状态机(FSM)或简称状态机,是一种计算的数学模型。它是一个抽象的机器,在任何时间都可以处于有限的状态之一。FSM可以根据一些输入从一个状态变为另一个状态;从一个状态到另一个状态的变化称为转换。

  • 有限状态机有两个必要的特点,一是离散的,二是有限的。基于这两点,现实世界上绝大多数事物因为复杂的状态而无法用有限状态机表示。

而描述事物的有限状态机模型的元素由以下组成:

  • 状态(State):事物的状态,包括初始状态和所有事件触发后的状态。
  • 事件(Event):触发状态变化或者保持原状态的事件。
  • 行为或转换(Action/Transition):执行状态转换的过程。
  • 检测器(Guard):检测某种状态要转换成另一种状态的条件是否满足。

一个FSM由三个关键要素组成:初始状态所有可能状态的列表触发状态转换的输入

finite state machine

v1,以直接的形式实现FSM。
v2,做一些重构以减少代码重复。
v3、引入状态转换表
v4,用OOP重构

v3

v3

v4

v4

myfsm's People

Contributors

icarus9913 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.