x


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!

more ▼

asked Jan 04 '12 at 12:31 PM

pretender gravatar image

pretender
512 122 134 146

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first
more ▼

answered Jan 04 '12 at 07:15 PM

_AinSoph_ gravatar image

_AinSoph_
31 2 2 3

(comments are locked)
10|3000 characters needed characters left

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.

http://en.wikipedia.org/wiki/State_pattern

more ▼

answered Jan 04 '12 at 02:40 PM

Kaze_Senshi gravatar image

Kaze_Senshi
162 15 18 19

ok, i will look into it, is it possible to implement this in javascript, and is there any example of how its done?

Jan 04 '12 at 02:45 PM pretender

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

Jan 04 '12 at 02:54 PM Kaze_Senshi
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x21
x1

asked: Jan 04 '12 at 12:31 PM

Seen: 1949 times

Last Updated: Jan 04 '12 at 07:15 PM