Questions tagged [state-machine]

A state machine is a model for designing systems which change based upon their current state and what input they receive.

Filter by
Sorted by
Tagged with
7
votes
1answer
272 views

Implementation of interface within state machine

This particular example is verilog, but my question is more about the state machine structuring, which would be relevant to both VHDL and verilog. So if I have a state machine, this one is fairly ...
5
votes
2answers
17k views

Designing simple state machine in C++

I have designed a simple state machine for the following diagram: I am seeking improvements from the community. I especially don't like two things: When calling ...
4
votes
1answer
3k views

State Design Pattern in Python

I'm trying to find the best - read: readable, maintainable, robust, threadsafe, usable - solution for a State Machine in python. For this I've been looking at the State Design Pattern. However I want ...
10
votes
2answers
296 views

Excel-formula-analysis state machine

This is one of my first useful scripts. I run it on a highlighted text selection within Notepad++, but I've provided a sample formula and commented out the Scintilla-specific references. I'm a rank ...
9
votes
2answers
893 views

Hierarchical State Machine in F#

I appreciate any feedback on where I might alter or improve my code for this project. This is an old attempt at implementing a Hierarchical State Machine in F#. I'm from a C#/OO background mostly. <...
6
votes
1answer
794 views

A variant of state pattern + C++ template FSM without state creation/destruction penalty

This is a variant of the solution posted here, without state creation/destruction penalty. Note that my comment in the original question about the simplification provided by C++11's inherited ...
14
votes
1answer
31k views

State pattern + C++ template

This finds its origin in the following reflection. In their book from 1995, the so-called gang of four (GoF) described the state pattern. What they were actually telling us in their description, is ...
6
votes
2answers
307 views

Design feedback for automaton to draw a checkerboard pattern

I've just completed the 3rd task of the 1st assignment offered by Stanford's programming methodologies (see the full resources for it here too). I just need some helpful feedback on how my code can ...
3
votes
1answer
117 views

How do I avoid explicit type switching when operation based on state?

I've encountered a problem that I have to solve using dynamic_cast to invoke different functions, depending on the type of class State family. I was re-factoring a ...
1
vote
2answers
125 views

Performing API calls from a mobile client, reauthorizing the session if necessary

I'm working on mobile app which doing requests to a server's API. I want to develop module that doing following: get authorization key already exists in previous session connect to server api and ...
6
votes
1answer
278 views

Automata theory, state reachability in Haskell

I wrote a small library to learn Haskell while studying Automata theory. I have some concerns on my algorithm to evaluate state reachability. That is, I think it might be improved if I can avoid ...
6
votes
4answers
595 views

State machine for handling Telnet sequences for an FTP server

I've asked Code Climate to generate metrics for the ftpd Ruby gem. It correctly identified the God class; I know what to do about that. But one of the smaller classes has me stumped. This is telnet....
4
votes
1answer
309 views

State Machine for Character

I come today with a state machine I'm currently working on. Problem: Given any State that the Character is in, a button press or combination of button presses can modify that state in a different ...
7
votes
2answers
15k views

Designing a state machine in C++ using the STL

I have this working code for C++ state machine using STL (not using boost state chart). The purpose of posting is two-fold: To share a simple and working code C++ state machine using the STL for the ...
24
votes
4answers
10k views

Simple Turing machine simulator

Yesterday I got a sudden urge to go from writing Python to something, well, more UNIX core-ish. I read some examples on here and decided I might as well put some of that stuff to use to test something ...
3
votes
1answer
535 views

State machine for upvoting/downvoting

I have a list of resources which can be voted on. There are 3 voting states: upvoted, downvoted and no vote. In a fashion identical to Stack Exchange voting, it follows these rules: If you upvote a ...
3
votes
1answer
2k views

Sample table-driven finite-state machine

We have interviewees write sample code, but now we want them to modify some simple working code. I came up with the following proposal, which is a syntax-directed interpreter implemented with a table-...