State machines are useful because they're 1) computationally fast 2) simple to implement 3) easy to read [up to a certain size] The big problem with state machines relates to the number 3 and regards the general concept of "state". Managing state is the challenge of computation! As you add states and transitions, the complexity increases dramatically, exponentially in some cases. This is why novice programmers strugg…
Why Developers Never Use State Machines
91–96 of 96 posts
Re: Why Developers Never Use State Machines
#92Earlier quoted context omitted.
I had the same reaction. Almost nothing but FSMs in game AI. Makes me wonder if we need to look beyond FSMs for the next level of intelligence.
The natural next step is a PDA. Perhaps you could use this type of system to model an AI that can get distracted or become faced with an intermediate task and then return later to the original objective?
Re: Why Developers Never Use State Machines
#93Re: Why Developers Never Use State Machines
#94Having used state machines a lot for embedded development, I find that they have one huge drawback: the resulting C code is unreadable, which turns maintenance into a nightmare. SM have a key quality: they are a compact and unambiguous way for specifying a behavior. If your system's behavior is set in stone, it's worth specifying it as a SM and implementing it as one. This SM is also great to include in a spec, stand…
the resulting C code is unreadable, which turns maintenance into a nightmare. I've been doing embedded development for a few years and I love our state machines, they're a pleasure to work with. Maybe yours just sucked.
enum {
APP_START,
APP_INIT,
APP_DO_TASK_A,
APP_DO ..
APP_FREE,
APP_QUIT
}
.. the center of your applications world! ;)Re: Why Developers Never Use State Machines
#95Can anyone recommend a good introduction to using state machines in code? Especially something in javascript/python? I know what an SM is and how it works, I just want to know how to use an SM library to actually do all these cool things.
A lot of the IBM Developer articles are apparently crap, but I found this one interesting and well done, some years ago. The article date looks different, now, and IBM has redesigned the site since I originally read it, but I think -- at a glance -- that it's the same article. http://www.ibm.com/developerworks/library/wa-finitemach1/ http://www.ibm.com/developerworks/web/library/wa-finitemach2... http://www.ibm.com/d…
Re: Why Developers Never Use State Machines
#96Earlier quoted context omitted.
A lot of the IBM Developer articles are apparently crap, but I found this one interesting and well done, some years ago. The article date looks different, now, and IBM has redesigned the site since I originally read it, but I think -- at a glance -- that it's the same article. http://www.ibm.com/developerworks/library/wa-finitemach1/ http://www.ibm.com/developerworks/web/library/wa-finitemach2... http://www.ibm.com/d…
I have to think that somewhere around 2007 IBM started offering massive bonuses for writing site content and HOWTOs.
However IBM did it, they were entered into some sort of site publishing schedule such that he'd lost track of just when they were coming out.
Seemed a nice enough fellow. From the articles and his bio, I imagine (perhaps incorrectly) his motivation was more pedagogical than remunerative.