- Home /
easiest way to implement finite state machine in javascript?
i was searching the forums and there are quite a few options when it comes to fsm, libraries, different approaches etc...a lot of data that does not help make my desicion what to do.
first of all i use javascript, and i know that ai soon becomes too complex to handle if you do not plan it, so what path should i take? use a library like playmaker, or try to code something my own. to be honest there are no simple javascript tuts about fsm.
if somebody has experience with this share with me. thanks!
Answer by _AinSoph_ · Jan 04, 2012 at 07:15 PM
There's an example in the Wiki http://www.unifycommunity.com/wiki/index.php?title=Finite_State_Machine
Answer by Kaze_Senshi · Jan 04, 2012 at 02:40 PM
You can try to use the Design Pattern State. At the start is odd but when you understand becomes easy. Also it is good if you need to change something later.
ok, i will look into it, is it possible to implement this in javascript, and is there any example of how its done?
I think that it is possible. Generally you can use design patterns in languages that are object-oriented, like javaScript.
There is one example that I found, generally you find design patterns from java, because it is one of the most popular object-oriented languages.
http://khousuylong.blogspot.com/2009/02/state-pattern-with-code.html