As of May 31, 2023, we have updated our Code of Conduct.

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.

26 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
0 answers
348 views

STTCL FSM framework based on the GoF State Pattern, Part I: The basic interfaces

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
πάντα ῥεῖ's user avatar
6 votes
0 answers
193 views

Character-based transitions (part of a lexer)

As part of my prep for the Code Review community-challenge (which looks like it will be Write your own programming language), I've been working on an LL(1) lexer generator in Rust. Yes, lexer ...
CAD97's user avatar
  • 1,934
5 votes
0 answers
2k views

Reducing complexity in NSView event handling code in Swift

My Cocoa event code always tends to descend into madness, I need to advice on how to reduce complexity. I've spend a few hours putting this example together. CanvasView is a layer hosting subclass of ...
boyfarrell's user avatar
4 votes
0 answers
708 views

Finite Automata stub in Rust

I wrote a finite automata implementation in C years ago. C's access to mutable, unsafe, raw pointers made it quite simple for me to link/relink the states of a finite automata. I read the official ...
John's user avatar
  • 323
4 votes
0 answers
995 views

C++ Finite State Machine - follow-up

This question is a follow-up from Object Oriented Finite State Machine. I vastly improved commenting and followed the suggestions from the answer. Additionally, I improved my tests and did some more ...
Justin's user avatar
  • 3,265
3 votes
0 answers
96 views

static macro-based State Machine implementation

While learning Rust for the past couple of weeks, I set out to use the type-system to build a static State Machine implementation in Rust. The goals: program in idiomatic Rust no runtime overhead ...
JeanMertz's user avatar
  • 131
3 votes
0 answers
88 views

Finite State Machine to segment Thai syllables

I am developing a FSM to segment Thai syllables with the following rules: Here are my util functions: ...
erip's user avatar
  • 916
3 votes
0 answers
60 views

"Academic interest" implementation of a Finite State Machine

Context I'm playing around the concept of a Finite State Machine. While I understand the basic principles behind it, I want to implement a simple, yet generic class which could be reused in the ...
Igor Soloydenko's user avatar
3 votes
0 answers
61 views

STTCL FSM framework based on the GoF State Pattern, Part II: Abstraction of asynchronous/concurrency features

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
πάντα ῥεῖ's user avatar
3 votes
0 answers
429 views

Linear finite state machine in ES6

I would love some feedback on my linear finite state machine. I say linear, as it can only handle one state at a time. I am also giving my method of how I -work- with the state machine, as I would ...
bitten's user avatar
  • 181
3 votes
0 answers
39 views

Backbone.model based state machine

I have created a class to keep track of some internal states. You can see it as a very simple implementation of a state machine ...
Anthony Kong's user avatar
3 votes
0 answers
123 views

Extracting dynamic behaviors of state machines to modules

This is my initial class. (I am not trying to reinvent state-flows again, just practicing) As you can see straight forward, it dynamically generates methods like .recommend,.recommend!, ....
roxxypoxxy's user avatar
2 votes
0 answers
41 views

Deterministic and nondeterministic finite automata in scheme

This is the implementation of both Deterministic Finite Automata (DFAs) and Nondeterministic Finite Automata (NFAs) on r7rs scheme, using only SRFI 1. The file automata.scm contains the implementation ...
phillbush's user avatar
  • 854
2 votes
0 answers
33 views

define a lisp function, that takes fsm , a transition and state-index and return the state obtained by the transition from the state

The state machine has the below specifications (defparameter *test-machine* (make-fsm :alphabet '(a b) :table '((2 1) (0 2) (1 0)) :initial 0 :accepting '(2))) ...
Ssunsshine's user avatar
2 votes
0 answers
107 views

Lock-free state machine

I've written a lock-free state machine in go and I would love to receive some feedback on it. Writing this library my main concerns are keeping it lock-free and very light-weight (no bells and ...
Eyal's user avatar
  • 299
2 votes
0 answers
131 views

Knuth Morris Pratt substring search algorithm

Below you can find a Kotlin based implementation of the Knuth-Morris-Pratt substring search algorithm. ...
gil.fernandes's user avatar
2 votes
0 answers
66 views

Time-dependent state machine with two outputs

Given a class BasicDataFeed whose purpose is to feed questions and answers into an artificial neural network, which is tested in a non-negotiable manner as follows: ...
Seanny123's user avatar
  • 1,463
2 votes
0 answers
92 views

STTCL FSM framework based on the GoF State Pattern, Part III: Policy based design of higher level State Machine constructs

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
πάντα ῥεῖ's user avatar
2 votes
0 answers
80 views

String matching

I recently came across a lecture on DFA. I tried to use it to determine whether a given 'search string' is found in the 'input string'. Please tell me if there is a better way. ...
Rajesh Bhat's user avatar
1 vote
0 answers
97 views

Self Running iterable state machine with Enums in Java

During development I needed to design a state machine with decision which runs to completion and performs state transition without the need to wait for events. So i come up with the following ...
Makis Papapanagiotou's user avatar
1 vote
0 answers
129 views

Finite State Machine

I'm beginner in rust. I would ask code review of my finite state machine. Main feature : static (event, state and transition) support pushdown It is the first step, second step is to use macro ...
Vaillant Etienne's user avatar
1 vote
0 answers
63 views

Simple Unity program for a research experiment

I'm developing a small C# Unity application to display stereoscopic images as part of a wider research study. Since the experiment consists of unique stages (Start, during a trial, between trials, ...
Richard Robinson's user avatar
1 vote
0 answers
30 views

Java UIState System

I am trying to come up with a UIState system that works well with Java UI. Before I show it I know I could add enums to help distinguish the states but I've left that out for simplicity. Here is what ...
Jay Laughlin's user avatar
1 vote
0 answers
441 views

21 Game (Nim) as Finite State Machine in Python

Feedback from previous posts of mine suggested that my approach to states was haphazard, which is not surprising since I hadn't really thought of games in terms of states before. I have since gone off ...
Robin Andrews's user avatar
1 vote
0 answers
87 views

3 state switch for a table sort

I have a data table with 7 columns. The first column is the index that increases from 1 to N and is considered to be in ascending order by default. The remaining columns are unsorted. I need to be ...
PirateApp's user avatar
  • 181
0 votes
0 answers
36 views

AI for OpenTTD - Decision Engine: Is this an appropriate use for the state pattern and raw pointers to states?

I'm writing an AI in C++ for OpenTTD. If you'd like to run it yourself, it's on Github here: https://github.com/marlonsmith10/empire_ai. This class is the decision engine. It will be responsible for ...
Marlon Smith's user avatar