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.
19
questions
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?...
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?...
15
votes
1
answer
35k
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 ...
11
votes
2
answers
201
views
Using state transitions to filter C comments
This is my second attempt at K&R 1-23,
Write a program to remove all comments from a C program. Don't forget
to handle quoted strings and character constants properly. C comments
don't nest....
9
votes
1
answer
1k
views
Simple parsing for string formatting (version 2)
This is my second attempt (version 1) at writing a string formatting utility which uses parsing. This time I more explicitly designed it as a finite state machine. I have very little experience with ...
8
votes
3
answers
1k
views
Efficient data-driven finite state machine
In creating this answer to a recent question, I thought I might write a fully worked example that implements a finite state machine in C.
The purpose is to implement the following function:
...
8
votes
2
answers
475
views
Does this simulation follow abstraction and encapsulation?
This below code implements a simulation of an ocean(as 2d-array of cells) which currently have Shark, fish or be Empty. User can run this simulation, as shown below:
...
8
votes
1
answer
9k
views
Deterministic finite automaton in Java
Formally, a deterministic finite automaton is a 5-tuple \$M = (Q, \Sigma, \delta, q_0, F)\$, where
\$Q\$ is the set of all possible states
\$\Sigma\$ is the alphabet
\$\delta \colon Q \times \Sigma \...
7
votes
5
answers
320
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 ...
6
votes
1
answer
1k
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 ...
6
votes
2
answers
342
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 ...
5
votes
1
answer
132
views
UTF8 Codepoint decode and length v.2
This is the complete rewrite of a function to decode an UTF-8 codepoints and return the encoding length (or 0 if the codepoint is ...
4
votes
1
answer
256
views
Time-dependent state machine
I keep having to write state machines that depend on time for various experiments I run and I'd like to know how to write them better. This state machine is for training a neural network by feeding in ...
3
votes
1
answer
1k
views
Simple Javascript state management class
So I needed very basic state management and notification for a small game-like thing I'm building. I decided to implement something like a finite state machine (but not quite, it doesn't transition ...
3
votes
2
answers
446
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 ...
2
votes
1
answer
1k
views
Object Oriented Finite State Machine
I wrote a little library for myself: implementing a generic finite state machine. I will be using this library in class assignments.
I clearly have little understanding of C++ templates because most ...
2
votes
1
answer
865
views
Very basic shell on microcontroller in C - follow-up
This is a follow-up of: Very basic shell on microcontroller in C
A few days back I've asked for a review on a simple shell parser in c. Based on the answers, I've restructured my code to use a table-...
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?...
1
vote
1
answer
258
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 @...