fsm

Combined states, FSM

Not sure this is the right place to ask, but is it "correct" to combine states of an FSM? Say you have an object with enum State { State1 = 1 << 0, State2 = 1 << 1, State3 = 1 << 2 } ; It just so happens that it makes sense to combine states, as in State myState = State1 | State2 ; however in FSM theory is this illegal...

Generic FSM for game in C++ ?

Hello, I was wondering if there's a way I could code some kind of "generic" FSM for a game with C++?. My game has a component oriented design, so I use a FSM Component. my Finite State Machine (FSM) Component, looks more or less this way. class gecFSM : public gecBehaviour { public: //Constructors gecFSM() { state = kEntity...

Is using a finite state machine a good design for general text parsing?

I am reading a file that is filled with hex numbers. I have to identify a particular pattern, say "aaad" (without quotes) from it. Every time I see the pattern, I generate some data to some other file. This would be a very common case in designing programs - parsing and looking for a particular pattern. I have designed it a...

What is the Pythonic way to implement a simple FSM?

Yesterday I had to parse a very simple binary data file - the rule is, look for two bytes in a row that are both 0xAA, then the next byte will be a length byte, then skip 9 bytes and output the given amount of data from there. Repeat to the end of the file. My solution did work, and was very quick to put together (even though I am a C p...

Finite State Machine parser

I would like to parse a self-designed file format with a FSM-like parser in C++ (this is a teach-myself-c++-the-hard-way-by-doing-something-big-and-difficult kind of project :)). I have a tokenized string with newlines signifying the end of a euh... line. See here for an input example. All the comments will and junk is filtered out, so I...

C++ FSM design and ownership

Hi, I would like to implement a FSM/"pushdown automaton" parser for this syntax: http://stackoverflow.com/questions/3025293/c-general-parser-with-scopes-and-conditionals which has already been "lexed" into http://stackoverflow.com/questions/3085070/finite-state-machine-parser I have the following: class State { public: virtual Sta...

Hierarchical state machine implementation in Erlang

Hi! I am planning a turn based game (a sort of board game), and the backend will probably be done in Erlang. The game logic part seems to be a fit for a hierarchical state machine, but I'm not sure about how to implement that in Erlang. Maybe I can spawn a separate process with each child fsm, not sure if this would work. Another opti...

How to parse template languages in Ragel?

I've been working on a parser for simple template language. I'm using Ragel. The requirements are modest. I'm trying to find [[tags]] that can be embedded anywhere in the input string. I'm trying to parse a simple template language, something that can have tags such as {{foo}} embedded within HTML. I tried several approaches to parse...

What is the best practice for a hierarchical state machine using the state pattern?

Hi all, I'm about to implement a hierarchical state machine in C# using the state pattern. As a guide I'm using this example. The example doesn't provide an answer regarding hierarchical states though. Unfortunately, I can't seem to find good examples elsewhere. My first thought is to create nested classed for the hierarchical states. B...

Good design to build a whole program as a FSM?

I have built a parser using a FSM/Pushdown Automaton approach like here (and it works, well!): http://stackoverflow.com/questions/3176110/c-fsm-design-and-ownership It allows me to exit gracefully and output a helpful error message to the user when something goes wrong at the parser stage. I have been wondering about a good way to get t...

Finite State Machine (FSM) and Android's Java

Hello, i'm willing to develop a soccer game for Android. Because the complexity of the AI, i really think i need to design it using a FSM (Finite State Machine) and not with a monster switch. Googling around i found some FSM written in Java, but nothing explicitly compatible with Android: i wonder if there is someone here that used a F...

Syntax for Describing DFA or NFA

Do there exists any Standard Syntax for Describing the Transition Table for an NFA or DFA ? ...

Designing a simple state machine generator

I know that designing state machine generators for regular expressions is not trivial, but what about simple strings (when I say a simple string, I mean something like "abcd" -- something without any regular expression syntax). I was thinking of writing a simple string matcher using state machines, but I wanted the state machine to be ge...