Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

The tag has no usage guidance.

4
votes
2answers
304 views

Why do I need a game loop with states, instead of init the next state in current state directly?

For example, it is common to see games with game loop and states: stateChanged(){ switch(state){ STATE.PLAYER_SELECT_CHARACTER: this.currentController=new PlayerSelectCharacterController()...
0
votes
0answers
38 views

Hierarchical state machine. Is there a term for the deepest nested state in a state configuration?

A flat state machine has one active state. In a hierarchical state machine (HSM), if the HSM is in a child state, it's also in it's parent state. So, an active state configuration of an HSM consists ...
0
votes
1answer
39 views

Can my state machines use state that is derived from model data?

I'm putting together some ideas and personal conventions on how to configure state machines when using a language specific library. Because I'm adding state machines to existing model classes in my ...
2
votes
1answer
57 views

Using state machines when managing remote resources

So I’ve got a service I’m trying to clean up. It responds to requests by starting a stopped server on Amazon EC2, waiting for it to come online, then configures a 3rd party piece of software on the ...
-2
votes
1answer
102 views

Finite State Machine odd number of bc at the end

I had this question in a school test: Design a non-deterministic FSM that receives all words over {a,b,c} that: Start with cc. Contain at least 1 ab or aca. Ends with an odd number of (...
1
vote
1answer
135 views

Why are next-state function and output functions of an FSM combinational functions?

From my understanding, combinational logic is dependent solely on input, and sequential logic involves state--memory. When explaining a finite state machine (FSM), however, it is said that an FSM ...
1
vote
4answers
1k views

So what exactly is a final state of a finite state machine?

I am playing around the state machine concept trying to better understand the best areas of their application. The formal definition of an FSM contains the following elements: finite non-empty set of ...
0
votes
1answer
701 views

Finite State Vending Machine Diagram

In class, we are asked to draw a finite state machine with the following instructions: Design a finite state machine to model a vending machine that accepts only quarters and gives a container of ...
1
vote
1answer
273 views

State machine with database records

I was re-learning about state diagrams this weekend, and realized that I may have been using them for years without realizing it. Suppose i have an order record, with a bunch of fields including ...
2
votes
2answers
92 views

How to model a statemachine in this case

I have a system where lot of messages come and go over network, each message to be sent or received goes through several states, state change occurs based on external events for example if the linked ...
0
votes
0answers
33 views

How do I know the depth of “k” for characterising set when testing FSM?

I am supposed to design the tests for state machine software. I have covered all states and all transitions. The last step is to detect the hidden states (states that look the same but internally ...
0
votes
0answers
72 views

Design for consuming list items for a state machine like structure

I'm trying to improve this document parser and there is one main loop that goes over all of the main elements (let's call them Nodes). Each step (Step) can either Consume or Ignore the Node that it is ...
4
votes
4answers
1k views

How should state machines handle exceptions in actions?

State machines, for example UML state machines, statecharts or other finite state machines, allow actions to be executed when a state machine takes a transition between states or is within a state. ...
3
votes
1answer
532 views

How does one combine the state pattern and the component pattern?

Suppose we have a class Player with classes PhysicsComponent, InputComponent and StandingState, DuckingState. The class Player itself does not have an input function, the InputComponent does. But ...
0
votes
1answer
52 views

Do I have to state the value of elapsed time in state-charts?

I am modelling a system that requires a state-chart before implementation. Given These Images: Main Questions: Can I use the word "Elapsed Time" if I do not know how long it will take to finish the ...
5
votes
2answers
362 views

A simple GUI app: states

I'm making a Windows Forms app: It is client-server. Authorization, then load some data from server, then send back some statistics from time to time. You should go through a bootstrapping procedure, ...
7
votes
2answers
538 views

How to store and validate data between state transitions?

I'm developing a largeish application that will have custom finite state machines. That is, the admin users of the application will be able to create their own state machines, limited by little pieces ...
3
votes
1answer
171 views

UML “direct substate” vs “transitively nested substate”

I am reading through Wikipedia's page on UML state machines. I don't understand where it says: A nested state is called a direct substate when it is not contained by any other state; otherwise, ...
3
votes
1answer
146 views

In OOP which object is common to update the state of an object when working with State Machines?

I'm about to implement my first State Machine and I'm left with one question, which is the acceptable coding form on who should change the state of the object/entity? Should the StateMachine change ...
4
votes
2answers
411 views

Trouble with circular dependency in state machine design

I am trying to develop the structure for a basic state machine that can also take in input and produce output. I've hit a bit of a mental block in trying to figure out how to model the relationship ...
2
votes
1answer
304 views

Is state pattern a wise architecture for a diagram application?

I'm designing a vector drawing app. I need to implemente copy and paste, shapes insertion, deletion and transforming while still being capable of including new tools with easy in the future. The way ...
3
votes
1answer
666 views

State machine with additional variable

When implementing a state machine and it comes to the fact that a transition depends on an external boolean a, or an enum value b which can be one out of three (which are set somewhere else in the ...
2
votes
2answers
2k views

Language to describe Finite State Machine

I'm doing a lot of code analysis using lexer and finite state machine. For time being I'm using table to describe FSM: | token | current state | target state | +-------+---------------+--------------+...
1
vote
2answers
836 views

State Design Pattern

I've come across the following State Design Pattern which seems extremely logical and simple to implement: class CeilingFanPullChain { private State m_current_state; public ...
0
votes
1answer
308 views

How do I manage a large state graph when building a scaleable finite state machine?

Lately I've been working on a project that involves parsing a toy domain-specific-language. While building it out, I realized that an efficient way to handle parsing tokens would be to represent the ...
6
votes
3answers
595 views

Can a generic piece of C code be converted to an FSM?

I understand that any language worth its salt can encode a Finite state machine. My question is the opposite, is it possible to convert an arbitrary piece of code ( say in C ) to a functionally ...
2
votes
4answers
113 views

How to explain to a vendor that when erroneous data is deleted/deactivated the application future state should be as if the data was never entered?

A major application we use has a bug that the vendor is calling (a swear word in our business) "working as designed". As a programmer / system analyst this is a bug - and against all I have been ...
7
votes
1answer
622 views

Finite state machine menu design

I'm creating an FSM in python (it's a step sequencer and sample pad based on a Raspberry Pi 2). Right now there are two states and the third is the Menu. This is handled by a class System which ...
2
votes
1answer
2k views

What is the alternative design pattern of a state machine that may have recursive state change?

I have a state machine like code, which has state A,B and C, with a function changeState(char i) which can change the state of a system, and each state can also call changeState(char i) to switch the ...
2
votes
2answers
174 views

Is there a well defined notion of 'before' and 'after' in finite state machines?

When working with finite state machines, is there or can there be a well defined concept of 'before' and 'after'. The ordering would, for example, tell me that one state is always considered to be '...
7
votes
4answers
1k views

How is a state machine different from any other computer program?

I have seen several implementations of "State Machines" on github. As far as I understand, a state machine takes input that may or may not transform its state into one of a finite set of other states. ...
3
votes
1answer
1k views

Should I use the State Design pattern for only two states? Also, what if one object's state is affected by another state?

If you only have two states for an object, is it worth it to still use the State Design pattern? The context is a multi-player, turn-based game environment where there are Game "Tables" that a player ...
3
votes
2answers
1k views

Should I use multiple state machines for a layered protocol?

When implementing a layered communications protocol are layers commonly implemented as state machines? I have an implementation of PMBus I am currently working on for an embedded device. I have a ...
2
votes
0answers
271 views

Finite State Machine user input tree

I'm drawing a Finite State Machine (which I'll have to implement later on) which is semi-automatic, i.e. some transitions require user input, some are decided on internal value. The problem is that ...
3
votes
1answer
701 views

Model of simple traffic simulation [closed]

I want to write a simple traffic simulation with one road intersection. First I thought of a cellular automata in the model but it should not be limited by an underlying discrete grid system so the ...
3
votes
2answers
208 views

Is there a good way (pattern) for adding a state to a finite state machine

So I'm working on a roguelike, and planning to represent the monsters using a finite state machine spot PC wander------------------->move ^ ^ | | \ ...
0
votes
1answer
124 views

How should I design a wizard for generating requirements and documentation

I'm currently working in an industry where extensive documentation is required, but the apps I'm writing are all pretty much cookie cutter at a high level. What I'd like to do is build an app that ...
1
vote
1answer
631 views

Implementing state-driven agents within an Entity-Component-System approach

A state-driven agent is an agent that performs an action based on its current state. The logic can be implemented through the use of a D-FSM that changes state depending on the Agent's "perception" ...
3
votes
1answer
455 views

How to process document state transition?

Imagine there is an application (ASP.NET MVC) that processes some documents. The document must be revised several times by different group of users. state/role rules: simple user can only publish ...
2
votes
0answers
442 views

State Pattern Code for embedded device - Dependency Injection of Device Objects in Context and State Classes

I'm wrestling with some code and I think I've finally gotten some state pattern code working with my events. I've got a simplified system that will work like this: This is my first go with State ...
5
votes
1answer
147 views

How to Recover from Inconsistent Job State without Database Polling

I'm working on scaling an application which is currently polling a mySQL database to send async jobs to a background processing system. A state machine is being used to keep track of the entities ...
5
votes
1answer
4k views

How to Implement a Parallel Workflow

I'm trying to implement a parallel split task using a workflow system. I'm using .NET but my process is very simple and I don't want to use WF or anything heavy like that. I've tried using Stateless. ...
2
votes
2answers
1k views

Dependency injection with Finite State Machines and the Interface Segregation Principle

I am trying to figure out what is the best way to setup a FSM and also keep my interfaces clean and use an IOC container to use DI. Let's just visit the Head First design pattern textbook example of ...
2
votes
1answer
525 views

Can all business logic be decomposed as a (declarative) state diagram on simple crud operations and conditionals?

This seems an extreme question probably but I'm wondering anyhow: Can all business logic be decomposed as a (declarative) state diagram on simple crud operations and conditionals? Already a lot of ...
1
vote
1answer
210 views

Converting a DFA to an NFA

I have an assignment to convert various language descriptions into NFAs and DFAs. Having graduated with my CompSci B.S. years ago and not touching the topic until my M.S. program, I am racking my ...
16
votes
4answers
2k views

Conceptually, how does one make a rules/constraints (not graphics/physics) engine for a game

I want to make a simple game similar to the choose-your-own-adventure books. The player is presented with a narrative text and gets to choose his action from a list of possibilities. This, in turn, ...
7
votes
4answers
1k views

Is a finite state machine an appropriate solution for this situation?

I was writing some test code as an example where I had a washing machine class. It has a door state that should be open or closed, and also a running state, either on or off. I want to prevent the ...
1
vote
0answers
186 views

Using a Finite State Machine for access management?

My intranet site uses LDAP and Active Directory to authenticate users. There are 2 kinds of Users: Managers and Employees. They are differentiated by having membership in a particular AD group. In an ...
93
votes
9answers
44k views

Are exceptions as control flow considered a serious antipattern? If so, Why?

Back in the late 90's I worked quite a bit with a code base that used exceptions as flow control. It implemented a finite state machine to drive telephony applications. Lately I am reminded of those ...
3
votes
1answer
743 views

Application protocols and state machines: designing a complicated server

I'm designing and prototyping a server that has the following characteristics: during the daemon's initialization it spawns nine "manager" servers, each of which solves one part of the overall ...