FiniteStateMachine icon indicating copy to clipboard operation
FiniteStateMachine copied to clipboard

Self loop in a state

Open salvob41 opened this issue 6 years ago • 5 comments

This is more a question than an issue: Is there a way to specify a self loop in a graph?

salvob41 avatar May 16 '18 20:05 salvob41

I don't quite understand what do you mean, can you give more details?

kubecz3k avatar May 17 '18 08:05 kubecz3k

Hi, immagine a situation where you select a piece in a board and go in a state "Piece Selection" from where you can move in a cell in the board, but you could also choose another piece (different from the one you selected), you need to re-enter into the same state (but reinitialize some variables).

Hope this picture helps: image

sorry for the quality of the picture.

EDIT: I think it is possible with this plugin, but the arrows are mixed up in a weird way: image

salvob41 avatar May 17 '18 11:05 salvob41

Never made such machine state but this should work fine. Yeah the arrows are not perfect in such case, maybe in the future I will made new ones that are based on the curves

kubecz3k avatar May 17 '18 14:05 kubecz3k

Oh no, I checked the source code it will not work. It's forbidden in code to try to change the state to the same state in which you are already (I don't thing anything will happen when OnAnotherCard transition will be served. You will need to create immediate state for such case... sorry

kubecz3k avatar May 17 '18 14:05 kubecz3k

I think this can be forced by calling the fsm.setState(fsm.getStateID()) (you could do it from inside of your transition when the condition is served). You need to test this however because there might be some side effects. (really haven't predicted this use case when I was writing the plugin)

kubecz3k avatar May 18 '18 11:05 kubecz3k