playMaker

Author Topic: what if an action could be an fsm!!!  (Read 5735 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
what if an action could be an fsm!!!
« on: February 21, 2012, 07:59:26 AM »
Hi,

 As I struggle through a state with too much actions ( gui actions...) I was thinking, maybe actions should be shown differently, etc etc and then thought: Why not an action as an FSM!

 Like aliessmael commented (http://hutonggames.com/playmakerforum/index.php?topic=1102.0), several fsm in one component would be nice, and he's right, it would be great so that several fsm can share common events and variables!

 But we also need encapsulated fsm for reusable process. so that we declare once a process and we can then reuse it ( this is different from the template system, tho it could be linked actually!).

So, a special action would simply allow a fsm to live within this action and access events and variables from this fsm. That is, the action would expose a linkage system between a variable declared within the action fsm and the hosting fsm, same with events).  Start state would be called within OnEnter, things like that. And the fsm would not be aware it actually is triggered within an action ( it would important to keep encapsulation intac)

To get out of this fsm, we would call a special action that would trigger the "FINISH" event, and to trigger transitions, a special action would be require to send event to the action state.

That would open a lot of possibilites!! Especially for gui since right now, we can't create complex gui because of the state restriction ( a gui element only exists when the state is active).

but the benefit goes way beyond gui stuff, we can create sub routines and reuse them at will, no more duplicated fsm!!!

 ahh.. dreaming...

 bye,

 Jean

aliessmael

  • Playmaker Newbie
  • *
  • Posts: 26
Re: what if an action could be an fsm!!!
« Reply #1 on: February 21, 2012, 10:33:13 AM »
Hi jeanfabre.
I feel i am useful   :)
 
several fsm in one component link is here
http://hutonggames.com/playmakerforum/index.php?topic=1104.0

making fsm as action can not give you good view for your FSM.
i suggest to keep every thing as it is just make some few changes
firs it is good to have grouping tool, to group some states (may be by drawing closed line around some states).

now you can deal with each group as single state( or you can say one FSM), it could receive global events and send events.

i have also another 2 suggestion
right now each event can have one transition output, instead of that it is good if one event can have more than one output. (for example from FINISH event you can link it to tow different states)
in this way you can make more than one state run at same time.

another suggestion is to be able to zoom in out , to look at all my diagram , or focusing on any group.

Thanks.





jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: what if an action could be an fsm!!!
« Reply #2 on: February 22, 2012, 12:35:04 AM »
Hi aliessmael,

Yeah, you do make some pertinent comments, so this is interesting discussions :)

  it's not like if currently we get an overview of what's going on anyway... since we only have one fsm open at a time.

In the end, an action being scripted or designed with an fsm doesn't change the idea and principle of what an action is (on paper):  Instead of doing it by script it does it with an Fsm. I don't really see anything wrong with that.

Yeah, sub fsm and grouped fsm is highly desirable. But I suspect the implementation is a lot of work and modifications for the fsm editor. I think that supporting fsm as actions could very well be a quicker approach to the reusability problems we have currently within fsms. But of course, this might not be suitable. I am just proposing stuff.

also, the idea of having multiple active state is against the principle of Fsm ( outside playmaker even: http://en.wikipedia.org/wiki/Finite-state_machine
Quote
"The machine is in only one state at a time; the state it is in at any given time is called the current state"
), so I don't think it should go that way. Everytime I need two active state, this means, I need two fsm. If I need to to do two things from a transition, either I do it sequentially, else I dispatch an event. I do have a lot of state where I send events to a series of Fsm for them to do something specific. I don't have a problem with this ( tho It took me a while to find the right process for this).

zoom, overview and all this is highly desirable too :)

 bye,

 Jean

aliessmael

  • Playmaker Newbie
  • *
  • Posts: 26
Re: what if an action could be an fsm!!!
« Reply #3 on: February 22, 2012, 10:18:23 AM »
implementing fsm as action of course will be very nice. especially if it is easy to implement.

but i still need more , this could be on far plane.
in the current PlayMaker system , i see the state as group, and actions as states running same time with order
this mean each state is group contains many states,which could be running at same time.

as i remember from my college, there is a special transition called (epsilon moves), and this transition make more than one state active.you can check the part of "NFA-ε"
http://en.wikipedia.org/wiki/Nondeterministic_finite_automata
as you can see from table , if the current state is S0 if ε event triggered it will go to {S1, S3}

but there is proof as i remember .any state machine with (epsilon moves) can be redesigned to be a union many of state machines without (epsilon moves), which is exactly what playMaker do.
but... this unions of state machine is not in one component.
i can not save them together, i can not share data between them.

this issue could be fixed by supporting ( ε transition ), or simplify communicating between different FSMs , like putting   a list of FSM in one component , each one with different page.
but i still prefer supporting (  ε transition ) , because i like to see all states in my state machines.