I'm making a non-deterministic finite state machine
Salutations fellow enthusiasts (◕‿◕)つ
This is the scenario, I'm creating a video game (Side scrolling action platformer) where the player character may be in different states depending on conditions. The special sauce is that the character may be in multiple states at once, and some states require the character to be in other states. (e.g. its logical that if the character be in the state of walking, the character should be in the state of moving as well, rather than one or the other)
The initial idea was simple, I considered the states as tags, boolean values either true or false. They were triggered to be such values based on conditions. Although, the system became more complex as I went on... 'AND's , 'OR's, and 'NOT's became involved along with cyclic dependencies.
The problem is that I require an algorithm to determine, when triggering a target state | tag, what the dependencies (tags that are dependent on / depended by target tag) are and what value they should be.
Another problem could be drawing up a dependency graph (see image as example). It's enough for a human to intelligently interpret, though a systematic way to validate that there are no 'impossible' cases would be beneficial (e.g. requiring a tag to be both true and false).
Doing research, trying to find a pre-made solution; I looked into Finite State Machines (FSM), though it was not the right fit for my use case because it may only be in one state at a time. Quite interestingly diving into the topic of Automata Theory, I learned that a FSM is often assumed to be a Deterministic Finite Automaton (DFA), and my case I want a Non-deterministic Finite Automaton (NFA) because it may be in multiple states at once. That doesn't solve my problem, just indicates that I have an uncommon case. (See sources: FSM - Stack Overflow, FSM - Wikipedia, NFA - Wikipedia)
Dependency resolution being beyond the scope of an NFA, I looked into Package Managers since they solve a similar problem (if not the same). According to a convenient article, what I'm looking for is the features of a dependency manager.
Going further in depth with Dependency managers, in comparison with my use case it gets quite complicated, but it helps by providing some high level instructions. (see sources: Write package manager - Medium, Dependency Manager - Devopedia)
With all that said, I'm working on a solution, and plan to release it so those interested may look into it, use it, give feedback, etc.
I'm using the Godot game engine, and native language GDScript which is similar to Python and relatively easy to understand.
I'll likely post an update to this thread here (MGSA), and on the Gamejolt Forums once I make more progress.
This idea / undertaking is part of my current personal project 3lg00gtach which is open source if you want to take a look
FSM - Stack Overflow
FSM - Wikipedia
NFA - Wikipedia
Package Manager - Wikipedia
Write package manager - Medium
Dependency Manager - Devopedia
tag flowchart - 2020-04-22.png
1920 x 1080 - 266K