ArthurSonzogni / Diagon

Interactive ASCII art diagram generators. :star2:
https://arthursonzogni.com/Diagon/
MIT License
1.47k stars 56 forks source link

Finite State Machine Support #46

Open TJ-Adams opened 1 year ago

TJ-Adams commented 1 year ago

Want to first say I love the project. I came across a scenario where I wanted to add a finite state machine and realized there wasn't support for it. I don't know if this is something of interest but just wanted to bring it up.

ArthurSonzogni commented 1 year ago

Hello!

Yes, adding support for state machine was one of the original goal. There are two tools:

The first only support directed acyclic graph. The scond only support planar graph.

None of them is the ultimate solution. Graph drawing is a difficult question.

Please let me know if none of the tools above solved your issue.

TJ-Adams commented 1 year ago

Hey,

The tools mentioned above come close but are not quite what I was thinking. One thing that I find very helpful for FSMs are the ability to show which input led to that state.

If I wanted to make a state machine for a stoplight I'd type something like:

green -> yellow
yellow -> red
red -> green

Using the planar graph support that would yield me:

image

Which is very close to what I want, but I'd like to specify the inputs leading to the state by doing something like:

green -> yellow : 50 seconds
yellow -> red: 8 seconds
red -> green: 32 seconds

and then get this:

image

You can ignore the syntax on the second example, I was just giving a random example. What do you think of that?

ArthurSonzogni commented 1 year ago

Yes, that would be awesome ;-) Difficult to make, though.