Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The video Finite State Machines explained by Abelardo Pardo[1] seems like a good introduction (I'm not familiar with the author; I just searched Finite State machine on youtube and found the first result which wasn't a jumbled mess of abstract or misused jargon).

It may seem simple, but that's truely all there is to finite state machines, a set of finite states and a set of events which cause transitions between states. Their specific applications to various domains is a much larger topic, but with a basic understanding, any application should be clear whenever it comes up. There's no one way to implement a state machine, and you've probably used them all the time, even if you haven't thought about them formally. For example, a simple but common 2-state machine takes the form:

   running = true
   while running:
       …
       if <some condition>:
           running = false
[1]: https://www.youtube.com/watch?v=hJIST1cEf6A


It could be written as:

    while True:
        ...
        if <exit condition>:
            break




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: