Comment by jenniferhooley
4 hours ago
Yeah, I agree with you. My experience has been very similar, when the actual game logic gets complex, BT's become a bit of a maintenance nightmare, making it super hard to reason about the system flow.
I ultimately landed on a flag-driven, hierarchical state machine. Instead of implementing a full tree traversal, which requires complex flow control nodes, I use bit flags to define my system's entire set of rulesets or invariants.
A state doesn't need to ask "what do I do next?" but rather "are my activation conditions met?" These conditions are defined as bitwise flags evaluated through standard bit-masking operations (AND, OR, XOR, etc.). For example, a state might only become active if flags IN_RANGE & GOAL_IS_NPC & PATH_BLOCKED. The flags allow me to mathematically encode complex prerequisite combinations as simple integer comparisons.
I found this approach makes the transition logic nice and clean. It shifts the burden from managing the flow (which is complex) to managing the data state (which is simple and deterministic). The system still feels like a full BT - it has hierarchy and sequential logic - but the decision process is purely data-driven, which makes it really easy to reason about even when there's a many of layers of complexity for each state/substate.
Hey, thanks a lot for commenting. That seems like a nice way to encode state. Did you ever have issues with multiple states being activated at the same time? I'll take some time to explore the hierarchical state machine, as I haven't seen an example of this short of HTN. Making it data-driven seems a nice and easy way to tackle the complexity. I like that
Is this not approaching how production rules/forward chaining works, or fluents in action logic? I think it is a nice system, but I am not sure if state machines are the right theoretical framework for it.