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
1 vote
1 answer
105 views

Rust state-machine lexer

I tried implementing a lexer in rust that peeks ahead at the next character and makes a decision based on that. However, i am told that this is bad practice, and instead i should be using finite-state-...
xxxxxxxxxx's user avatar
2 votes
1 answer
208 views

Templated state machine

I decided to try a hand at writing a simple state machine. The StateMachine class accepts any number of classes as template arguments, along with a base class. The ...
Ross Lombardi's user avatar
1 vote
1 answer
66 views

State machine for parsing GitHub URL formats

A while ago, I wrote a small Rust crate for parsing & generating URLs for GitHub repositories in various formats (HTTPS, SSH, git://, etc.), with the parsing done using regular expressions with ...
jwodder's user avatar
  • 302
1 vote
1 answer
33 views

Framework to create turing machines with binary increment example

I created a way to create turing machines and implemented one that increments a binary number as an example. This is the turing machine itself: ...
Cookie04's user avatar
  • 125
0 votes
1 answer
105 views

Simultanous states in a state machine

In Dungeons and Dragons, we have many spells, e.g. the Charm spell to get anyone to do what you want, the Web spell to entangle someone, the Invisibility spell to make yourself invisible (but once you ...
prestokeys's user avatar
  • 1,351
1 vote
1 answer
270 views

Another Vending Machine implementing State Pattern

I previously asked for a review for a Vending Machine implementing State Pattern in this linked post. And received an answer from @radarbob. The code below is my revised attempt based on some of @...
fourbeatcoder's user avatar
2 votes
2 answers
175 views

State-machine class based upon arduino toolchain

In my quest to search or develop the 'perfect' state machine I have built the following class. With the class you can make a state machine object which comes with timing and transition methods. Being ...
bask185's user avatar
  • 136
0 votes
0 answers
37 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
2 votes
0 answers
45 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
8 votes
1 answer
550 views

Haskell Tic-Tac-Toe (with automation and GUI)

There are already many Tic Tac Toe posts. But as far as I can tell, none of the ones in Haskell are complete with a GUI Here is my implementation with Gloss. Gist Link for convenience ...
Agnishom Chattopadhyay's user avatar
2 votes
2 answers
500 views

Game States / Pong: SFML Box2D EnTT

Trying to make a little 2D engine I can play with. The end goal is a simple multiplayer PVP game just using shapes. I will make one version using ECS and one using OOP for learning. This is the shell ...
Teach_Me_Something's user avatar
1 vote
0 answers
64 views

State machine in C for SDL game [closed]

I want to create a state machine for menu in my SDL game. So this is my code without the SDL. I just want to ask if this is a good way to create it. I am trying to implement a screen and then mouse ...
matthews's user avatar
1 vote
1 answer
168 views

Simple state machine

I tried implementing a state machine in C. This is for a Stratosphere Balloon and I wanted to use a state machine to make it better. This will be later implemented in ARM CMSIS. The state function ...
moonraccoon's user avatar
2 votes
0 answers
34 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
3 votes
1 answer
83 views

Sequence state machine

I tried to parse command line arguments. The program requires four arguments. I iterate over the arguments. If the argument is an option, I process the option. Otherwise the argument is one of the ...
ceving's user avatar
  • 413
1 vote
0 answers
125 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
1 answer
110 views

Simple State Machine and Transition Table

The goal is to have well defined state transitions, and the ability to provide the next event to execute. I'd like to know if this is a proper implementation of State Machine, considering how states ...
J. Doe's user avatar
  • 45
1 vote
0 answers
138 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
2 votes
2 answers
350 views

Scalable design of a system with multiple state machines, where valid state transitions depend on the state of other machines

This is a pretty huge question, however, I would appreciate it if you could just review the design and not my implementations of it. The Implementation and test sections could be ignored, they are ...
Blue7's user avatar
  • 373
1 vote
0 answers
65 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
6 votes
1 answer
2k views

Toy Robot Simulator

I know this code worked as I've tested it with the case tests commented below in the code, and even added a few of my own, but the developers who were testing me came back with the following critiques:...
Eliseo D'Annunzio's user avatar
3 votes
1 answer
293 views

Finite State Machine / Scene Manager in C

I'm new to C programming but this is my attempt at a Scene/State machine. I haven't had a code review before so I'm guessing this is gonna hurt :D § Preliminary SceneFSM manages Scenes, one Scene "...
whoshotdk's user avatar
  • 143
2 votes
0 answers
116 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
  • 309
10 votes
3 answers
1k views

The parking machine implementation

I am interesting in the topic of finite automata, so I started over by implementing a parking machine from this video: Computers Without Memory - Computerphile to understand conceptions. Didn't do ...
MiniMax's user avatar
  • 862
6 votes
1 answer
111 views

Hardware Clock Divider

I have created a clock divider that works as follows: If the division factor is 0, pass the clock through unchanged. Otherwise, flip the output clock signal after the specified number of input clock ...
rlee827's user avatar
  • 313
7 votes
5 answers
333 views

Simple tokenizer v2 - reading all matching chars at once

I have rewritten my tokenizer according to most of the suggestions from the previous question here. API It now reads all chars as long as they match the pattern. I use three types of attributes to ...
t3chb0t's user avatar
  • 44.1k
3 votes
2 answers
456 views

Simple tokenizer v1 - reading char by char

I was feeling like writing a new Uri parser. The previous one was too limited and wasn't able to parse the authority part. This one is also based on the pretty ...
t3chb0t's user avatar
  • 44.1k
2 votes
1 answer
584 views

A Simplistic Finite State Machine Generator

I have designed a compile time Finite State Machine generator. I have chosen to use some of the features of C++17 such as parameter pack expansion, fold expressions and lambdas to keep the complexity ...
Francis Cugler's user avatar
4 votes
2 answers
53 views

Extract lines under the specified heading

I wrote the following working code, which I just can't stomach: ...
Merc's user avatar
  • 547
3 votes
1 answer
71 views

State machine translates text into executable python code [v2]

A few days ago I started writing my own compiler-like program which has the goal to compile plain text into executable python code. After I let my first version review here, I made huge changes to the ...
TVSuchty's user avatar
  • 595
6 votes
1 answer
82 views

F# pattern matching to determine the state of a bank account based on past events

I am writing an event sourced system in which I need to have the state based on the events that already occurred for a given bank account. The events are defined such as: ...
Natalie Perret's user avatar
4 votes
1 answer
326 views

Implementing Hangman using a State Pattern

I decided to implement a Hangman game using an object oriented State Pattern design. This is one of my first actual OOP as I normally write functional code. Code use: ...
Andrew Allen's user avatar
1 vote
2 answers
414 views

Turing machine schoolwork

Our teacher doesn't give much feedback on our code itself. Was just looking for some feedback on how I could improve on this. This is the method that tests the string against the Turing machine that ...
Christopher D.'s user avatar
3 votes
1 answer
372 views

Finite state machine for chasing and attacking a target

My questions are: How can I improve my implementation of the FSM model? Should Finite State Machines have functionality for Adding and Removing states from table? (Since I can only be in one state at ...
Mr Impact's user avatar
8 votes
1 answer
330 views

Designing yet another a state machine

I wanted to design a state machine with a few goals in mind: Encapsulate state logic within individual classes to keep them decoupled. (I'm very curious what the community thinks about this in ...
Tom's user avatar
  • 183
2 votes
1 answer
282 views

Scheme: FSM substring search

I have been working on a function that return a FSM that searches a specific word based on the argument of the constructor. The idea was to use those routines as means to learn about regular ...
user avatar
6 votes
1 answer
3k views

C++ CLI Console Menu Statemachine

I am trying to find the best way(/most efficent way) to setup my console program's menu. The way I have it set up is that I have a Menu class and then I use a menu pointer called currentMenu and I ...
Samuel Habtu's user avatar
4 votes
3 answers
3k views

Finite State Machine in C++

I made a state machine. You can press 0 and 1 to switch between the hypothetical menu and playing state. I hope you can help me improve it further. StateManager.h ...
Featherball's user avatar
3 votes
0 answers
98 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
1 vote
0 answers
456 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
6 votes
2 answers
347 views

Finite state automata

This is a non-deterministic finite state automata (NFA) meant to be used with a Regex engine. To show some example usage, suppose you wanted to construct an NFA for the regex ...
User319's user avatar
  • 1,132
4 votes
0 answers
711 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
3 votes
0 answers
90 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
1 vote
1 answer
841 views

Implement a Finite State Machine in ES6 [closed]

I have built a simple finite state machine that models an even simpler fictitious bank account system. Any given account can be in one of three states at any time: Open, Closed, or Held. I have a ...
Sebastián Mestre's user avatar
2 votes
1 answer
219 views

Push Down Automaton to detect RNA hairpins

For one of my assignments I am supposed to write a Push Down Automaton. It's supposed to receive a string that has to be checked if it's an RNA Hairpin. For example: gacgcaaguc would be one, since ...
Lanorius94's user avatar
2 votes
0 answers
132 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
1 answer
72 views

Python coroutine structure

I've completed Advent of Code's Day 9 in Python3, trying to use it to teach myself coroutines. I'm very familiar with generators, but I've pretty much never used coroutines before. I've ended up with ...
Patrick Stevens's user avatar
2 votes
1 answer
350 views

Simple state machine based command-line argument parser

I'm in the process of learning to write idiomatic JavaScript code so naturally I'm parsing command line arguments. My approach to this is to have a simple state machine. The parser should work as ...
ceiling cat's user avatar
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
2 answers
1k views

DFA creation from string

I have fairly simple Python 3 code that creates a DFA from a string. It works great, but I believe it can be made more efficient. There are a total of 3 loops: First iterates over the string Second ...
theblindprophet's user avatar