News for hackers. Stuff that matters.
Re:State Machines by ajuc on Tuesday May 15, 2012 @03:22AM (#3975403)
It's possible you use state machines and don't know it :) Have you ever used loop with if inside, that dispatches based on value of some variable? That's state machine implementation in structured language.

I've encountered such code many times in our codebase.

Or maybe you used some business process engine (like jbpm) - that's also state machine.

I've even made jbpm-like engine in javascript for my html5 game - I use it to write quests in my game, and I plan to refactor dialog trees to also use it.

It's graph with nodes and transitions, nodes specify actions game should do, transitions specify conditions player has to do to move to next node.

Here's code if anybody's interested: https://github.com/ajuc/pefjs

And here's graphical editor for graphs: https://github.com/ajuc/jsDotForPefjs

There are no comments on this comment yet.