finite-state-machine

Arbitrary Digit Counter

I need a counter algortihm which use arbitrary given digits for counting purpose. My code is similar to this: static char digits[] = {'x','y','z'}; /* Arbitrary number of arbitrary digits. */ int i; for(i=0; i<100; i++) { printf("%s\n", get_next()); } My expected output: x y z yx yy yz zx zy zz yxx yxy yxz yyx yyy yyz yzx yzy yz...

Design Pattern problem involving N states and transitions between them

Hi All, I have a problem at hand and I am not getting which design pattern to use. The problem goes as such: I have to build a system which has 'N' states and my system has to do a transition from any state to any other state depending on some conditions. Ex: On condition 1, movement from State 1 to 3 and on condition 2 from state 1 ...

Approaches for using and analyzing set data in time.

I am designing an interactive installation for a gallery where I will receive input telling me which of 8 input transducers have been bridged. For example if someone touches strip number 1, I will be able to detect that. For convenience let's notate that as {1}. If they touch 1 and 2 simultaniously, I will be able to detect that connecti...

How do I communicate with the user in a finite state machine implementation?

Basically I have a custom implemented finite state machine that mostly listens for hardware switch state changes for initiating transitions, but some things need communication with the user... For instance, the user needs to tell it whether to repeat or save and reset. I have a pretty good idea of how to do it... I can raise events whe...

How to visualize an Erlang gen_fsm

Do you know of any existing tool to graphically render the diagram of an Erlang gen_fsm starting from the source code? ...

How to Make a Basic Finite State Machine in Objective-C

I am attempting to build an FSM to control a timer in (iphone sdk) objective c. I felt it was a necessary step, because I was otherwise ending up with nasty spaghetti code containing pages of if-then statements. The complexity, non-readability, and difficulty of adding/changing features lead me to attempt a more formal solution like this...

How to perform FST (Finite State Transducer) composition

Consider the following FSTs : T1 0 1 a : b 0 2 b : b 2 3 b : b 0 0 a : a 1 3 b : a T2 0 1 b : a 1 2 b : a 1 1 a : d 1 2 a : c How do I perform the composition operation on these two FSTs (i.e. T1 o T2) I saw some algorithms but couldn't understand much. If anyone could explain it in a easy way it would be a major help. Please not...

Rails: Multi-Step New User Signup Form (FSM?)

I've read the "Create Multi-Step Wizard" in Advanced Rails Recipes. I've also read and re-read the documentation for the updated FSM I'm using called Workflow, and looked here and here. The Advanced Rails Recipe focuses on records (quizzes) that already exist, and doesn't cover creating new ones. The Workflow docs don't cover any code fo...

how useful is Turing completeness? are neural nets turing complete?

While reading some papers about the Turing completeness of recurrent neural nets (for example: Turing computability with neural nets, Hava T. Siegelmann and Eduardo D. Sontag, 1991), I got the feeling that the proof which was given there was not really that practical. For example the referenced paper needs a neural network which neuron a...

abusing ragel, possibly need new approach / tool

Hi, I'm trying to use Ragel to implement a simple yes/no fsm. Unfortunately the language specification consists of the union of about a thousand regular expressions, with * operators appearing once or more in the majority of them. So, the number of possible states explodes and it seems it will be impossible to use Ragel to generate an f...

Creating a Basic Formula Editor in JavaScript

I'm working on creating a basic RPG game engine prototype using JavaScript and canvas. I'm still working out some design specs on paper, and I've hit a bit of a problem I'm not quite sure how to tackle. I will have a Character object that will have an array of Attribute objects. Attributes will look something like this: function(name...

What is the best way to implement a FSA/FSM in Java

Hi every one, I have a big finite state automaton with like 50 states and each state has avg. 3-4 transitions to other states. So I don't think the "state pattern" is suitable for this. This FSM tends to be a spellchecker and morphological analyzer for some agglutinative language. What is the best way to implement a FSA/FSM in Java or ...

What is an appropriate data structure or algorithm for producing an immutable concrete syntax tree in a functionally pure manner?

Given a LL(1) grammar what is an appropriate data structure or algorithm for producing an immutable concrete syntax tree in a functionally pure manner? Please feel free to write example code in whatever language you prefer. My Idea symbol : either a token or a node result : success or failure token : a lexical token from source text...

Implementing Hierarchical State Machines in C

I'm a bit confused about how to implement my state machine. I already know it's hierarchical since some states share the same action. I determine what I need to do by these parameters: Class (Values are: Base, Derived, Specific) OpCode Parameter 1 - optional Parameter 2 - optional My hierarchy is determined by the Class and the OpC...

How can I name and organize methods used by a finite state machine?

In the following code you'll see a simple lexer that conforms to the following regular expression: \d*(\.\d*)?([eE]([+-]\d+|\d+))? If I were to use this design for something more complex, all of the anonymous delegates would be a nightmare to maintain. The biggest challenge I am facing is what to name the methods that would act as cho...

Is there a simple .NET code generator for a Event-driven finite state machine?

Is there a simple .NET code generator for a Event-driven finite state machine? I am tired of doing this by hand for user-interface objects. I just need the enum definition, the switch statement, and each function call. I do not need a "library". See Event-driven finite state machine at http://en.wikipedia.org/wiki/Event_driven_finite_s...

Speed of finite state machines - OO vs procedural

Hey all, I am designing a program that will accept from input a series of tokens and feed them to a finite state machine which I have designed. I have designed a test finite state machine in object-oriented style, with structs for the machine itself and transitions, etc. but the application I am writing is one where speed is very importa...

Creating an Exclusive Or from two Deterministic Finite Automatons (Deterministic Finite-State Machines)

Two DFAs (Deterministic Finite Automaton or Deterministic Fininte-State Machines - Which will be called DFAs from here on) Defined over the set DFA 1: L1 = {Q1, E, D1, s1, F} DFA 2: L2 = {Q2, E, D2, s2, F} Q is the list of states. Ex 1, 2, 3, 4 or a, b, c, d E is the the language Ex. 0, 1 D is the transition set Ex. {(a,0,b)} state a ...

Simple State Machine Problem

Hi all, I have a very simple FSM which should drive some output signals of an external RAM. The problem that I have comes with handling the data bus which can be input as well as output... I am not too sure how I can handle best this case in my FSM. The problem comes from the following line: v.sram_data <= io_sram_data; Obviously...

Syntax for Describing DFA or NFA

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