pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.5k stars 525 forks source link

elegant approach for a transition condition #432

Closed ghost closed 4 years ago

ghost commented 4 years ago

Thank you for this lightweight library. I have used it extensively for configuring states of my dialog system.

Here is a condition I want to emulate in best possible way ::

I have states and transitions already defined which works perfectly. I want to add a new state, let's say "X-state" which is triggered by any of the already defined states if the trigger word is let's say "ABC". It should work for all the states basically something like ::

self.machine.add_transition(trigger='XYZ', source='[*ANY STATE]', dest='X-state')

Possible ??

ghost commented 4 years ago

ahh okay, It's all there in the documentation - to use wildcard self.machine.add_transition(trigger='XYZ', source='*', dest='X-state')

closing it - I should read the documentation more thoroughly.