State-Machine for developers

This project implements a Finite-State-Machine (FSM) designed to be used in games.
Furthermore it implements even a Stack-Based-FSM (SBFSM). So you may tell it to ‘continue with the last state before the active one’.
You describe your FSM using a nice and well documented DSL (Domain Specific Language).


– Oh! Please don’t forget to star the repo, if you like it. Thx. –

It comes in two flavors (described in the README.md). A plain state-machine and one that needs MonoGame since it uses the GameTime object. That enables you to ‘time’ the transitions (say: duck, then stand up after 5 seconds).

Feel free to comment, PR or just use it.
Unlicense.
Nuget provided in README.md on Github.

(Since this is not a game, maybe I should move this topic, but I don’t know where. Suggestions are welcome.)

2 Likes

Nice, this seems to be very useful! :slight_smile:

I didn’t really look into the code, but it may be useful to just use TimeSpan for the elapsed time instead of GameTime or a custom struct if just a TimeSpan isn’t sufficient to make the code work standalone.

Hmmm. You’re right of course.
I wanted it to fit seamless into the MG.Update(GameTime) I think. But now, days later, I really don’t know why I didn’t do it as you say…
Added it to issues for further considerations. Thx.

1 Like

Looks nice ! Maybe useful for AI ! (or not ?)

Hmmm. Yeah. I imagine it would be. You could model it as states traversing on certain input… At least on a top level.

The MonoGame StateMachine now is a PCL.

I plan to re-unify the two libraries… but I don’t have time at the moment :blush:
It’s on my list.