simple state machine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey0
    New Member
    • Jan 2008
    • 142

    #1

    simple state machine

    Hello,
    I just want to try to implement a simple State Machine and I'm reasoning whch class I need
    Code:
    function Machine(startState) {
    	this.startState = new State(startState);
    	//states list
    
    	this.raise= function(eventName) {
                //alert(eventName);
      	}
    }
    
    function State(idState) {
    	this.id = idState;	
            //actions list
    }
    function Event(eventName) {
    
    }
    function Action() {
    	//execute code
    }
    I dont' know if it's clear what I need to do; what it's not clear to me is how design the things! What must Event class contain? Must each state contain a table like 'for each event says which is the target state' ? . Any helps?

    thanks
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    we can’t really help when we don’t know about it. currently I have no idea about the purpose and the usage of the objects concerned, thus I’m as helpless as you.

    PS. JavaScript is a prototype based programming language. the concept of classes as you know it from other programming languages does not exist here.

    Comment

    • mickey0
      New Member
      • Jan 2008
      • 142

      #3
      Originally posted by Dormilich
      we can’t really help when we don’t know about it. currently I have no idea about the purpose and the usage of the objects concerned, thus I’m as helpless as you.

      PS. JavaScript is a prototype based programming language. the concept of classes as you know it from other programming languages does not exist here.
      I just need to give a definition of a State Machine. It's in js but I would have the same problem with every language.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        try the Turing Machine.

        Comment

        Working...