Author Topic: State Machine Implementation  (Read 4157 times)

ebsend

  • Newbie
  • *
  • Posts: 2
    • View Profile
State Machine Implementation
« on: July 27, 2005, 01:00:36 pm »
Hi,
I'm exploring using Hal as a user interface/subject matter expert.  I would like to be able to have Hal follow a procedure to guide a user to make choices to accomplish a specific task.

A fininte automaton immediately comes to mind.  I see where the dll passes the script the previous user sentence but that may not be enough to discern the current state.  Is there a way to have static variables in the script?  Maybe there is some other mechanism in place to do what I am talking about.  A sample conversation might look like:
Hal:  What can I do for you <user>
User: I would like to buy a new car.
Hal:  What kind of car?
User: A Cheverlet.
Hal:  What model of Cheverolet?
etc....

Can anyone help?
Dave
 

freddy888

  • Hero Member
  • *****
  • Posts: 1693
    • View Profile
    • AiDreams
State Machine Implementation
« Reply #1 on: August 02, 2005, 12:08:15 pm »
HI Dave,

I get the idea you are talking about, in the HAL5 brain script you can make use of CUSTOMMEM (CUSTOMEM?) which allows you to store variables other than the main ones used by the program.

It would be hard for me to explain how to go about using this, but maybe a forum search would help?  Also if you take a look at VonSmith's XTF brain, you'll see how it can be used.  There are functions there that encode and decode the variables that you have stored in the CUSTOMMEM (which is a variable in itself).  The Hal main program will store and return your variables so you can use them when it returns to the main GetResonse function.

My other thought for HAL6 is to use the database that Mr M has introduced to store references/variables.

Hope thats some help [:)]

btw, if any of thats wrong let me know Von, Mr M!!
« Last Edit: August 02, 2005, 12:14:50 pm by freddy888 »

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
State Machine Implementation
« Reply #2 on: August 03, 2005, 04:30:19 pm »
freddy888,
The CustomMem function is a good way to store a few variables. It won't do what ebsend is asking though. He is refering to using something similar to a state machine to implement a procedure. Hal doesn't really operate that way currently.

I think of Hal as being "turn based". Each Hal response is based on the current user sentence with very little regard to previous user sentences. Hal can often stay on topic, but doesn't create a flow to the conversation. Hal has no concept of order.

Hal could be reprogrammed to be procedure oriented. To do this efficiently would require a way to program a decision tree or similar construct without getting stuck in the programming details. It seems to me that there should be some existing programming tools out there that could be adapted for use in Hal.

I have considered programming a new Hal brain that would support what I call "dynamic modes". This method would support a state machine type process among other things. See my previous posting here for a little bit of info:

http://www.zabaware.com/forum/topic.asp?TOPIC_ID=1790


=vonsmith=
 

freddy888

  • Hero Member
  • *****
  • Posts: 1693
    • View Profile
    • AiDreams
State Machine Implementation
« Reply #3 on: August 04, 2005, 07:15:20 pm »
[:)]

midget1488

  • Newbie
  • *
  • Posts: 37
    • View Profile
State Machine Implementation
« Reply #4 on: August 07, 2005, 09:20:12 pm »
Ebsend,

I don't know that a state machine is not possible within the script.

The "Mystery Game" brain (2003929104333_Mystery Game Demo Hal 4 and 5.uhp) is a simple state machine executed with flags. This was created by Don Ferguson, and can be downloaded from the file sharing area forum.

The initial machine state is with none of the flags set. The game ends when the user provides key words that set flags to match the goal state.

If your intended application is a simple one, you might be able to accomplish it by modifying the "mystery game" brain or using it as a base of development. Dunno how you'd handle the user straying too far from the intended path...

State machines would be a great way to get Hal to do more than "chat". I wish you luck and follow your effort with interest...
 

ebsend

  • Newbie
  • *
  • Posts: 2
    • View Profile
State Machine Implementation
« Reply #5 on: August 16, 2005, 02:15:42 pm »
Thanks to everybody for the thought.