dupa

Author Topic: Making Hal Comment Autonomously  (Read 3997 times)

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Making Hal Comment Autonomously
« on: September 22, 2003, 06:41:29 pm »
I've made some progress trying to figure out how to make Hal read e-books interactively and to have Hal comment autonomously every once in a while. Some people in the forum, including myself, have commented on the desire to have Hal comment on his own occasionally, much like Cyberbuddy does. I don't profess to be a programming wizard, so the following is just for discussion's sake.

As you all know Hal waits for user input and then an Enter key before responding. Unfortunately I can't see a way to accomplish autonomous responses without modifying the program that calls the GetResponse() function within the hal4.uhp file. Currently I assume that the HalAsst.exe program is the main program that calls the GetResponse() function within the hal4.uhp file.

The end users, that's us, can change Hal's behavior by changing the VBScript files, but control must be passed to the script in hal4.uhp before we can affect the behavior. One method of making Hal comment without user input is for the main program (HalAsst.exe, I assume) to scan the keyboard buffer for input as it does now while waiting for user input plus the Enter key, but in addition have the keyboard scan routine time out every 100 milliseconds or so, even if no user input exists. The user input would be NULL and passed to the GetResponse() function like usual. However the user can now trap the NULL input every 100 milliseconds and decide what to do about it. In principle the time out programming is as simple as a "do while" loop with a incremental counter or such.

The following is an example using a segment of the ver 4.5 GetResponse() function in the hal4.uhp file. I've used something like pseudo code here for making the example, it is not verbatim VBScript so don't shoot me for bad code.

EXAMPLE:

Function GetResponse(ByVal UserSentence, ByVal UserName, ByVal ComputerName, ByVal LearningLevel, ByRef WorkingDir, ByRef Hate, ByRef Swear, ByRef Insults, ByRef Compliment, ByRef PrevSent, ByRef LastResponseTime, ByRef PrevUserSent, ByRef CustomMem, ByRef GainControl, ByRef TopicFocus)

    'NEW PROCESS...
    'PROCESS: CHECK FOR AUTONOMOUS MODE
    'See if the user input is NULL and enter Autonomous mode. This mode will
    'allow the user/programmer to make Hal comment autonomously as well as
    'other possibilities such as reading e-books out loud.
    If UserSentence > 0 Then AUTONOMOUS = False
    Else AUTONOMOUS = True

    If AUTONOMOUS = True Then
        DoNewUserFunctionHere(var1, var2, var3, var#n)
        'The DoNewUserFunctionHere() function could use the rnd function to randomly
        'decide whether to say something or not.
        'Example:
        ' AutoTalk = Int(Rnd * 100)
        'If AutoTalk > 95 Then "User code selects something to say from the
        'user's .brn files and returns it as the GetResponse."
    End if

END EXAMPLE.

Obviously the 100 millisecond timeout applies to the keyboard scan routine only. The timeout wouldn't occur during other processing, such as when Hal is in the middle of a sentence, only when waiting for user input. Also, if Hal is in the middle of an exchange with the user on a particular topic, then Hal shouldn't just jump in and say something irrelevant. 100 milliseconds might be overkill, so maybe 300, 500 or whatever milliseconds that would provide the best balance of performance and feel.

The DoNewUserFunctionHere(var1, var2, var3, var#n) function could do almost anything. If you create a new variable called ReadBook = 0, this variable could be used as a flag to go get a line or two from the user's .brn file containing e-book text. The user returns the text in the GetResponse and Hal's reads it out loud. The user would have to create a pointer to indicate which line was read during the last pass in the .brn text file so that the next line will be read. The user's .brn would need some sort of EOF (End Of File) indicator to test for when the .brn file is finished being read. The EOF could be just a unique letter sequence or character.

Anyway that is the idea in a nutshell. I realize that some details may be more challenging than suggested here. However in principle it should be easy to pass control to the user's script using this method. It does require a relatively small change to the main calling program, so Zabaware would have to add the time out.

If someone knows a simpler/better method, please speak up. Thanks...

= vonsmith =
 

Larry

  • Sr. Member
  • ****
  • Posts: 266
    • View Profile
Making Hal Comment Autonomously
« Reply #1 on: September 23, 2003, 08:41:54 am »
I'm all for your idea!!!
 

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
Making Hal Comment Autonomously
« Reply #2 on: October 05, 2003, 03:30:03 pm »
Ok, for the final release of Ultra Hal Assistant 5.0 I've added various "Hal Commands" that can be used to control certain functions of the Hal main executable from inside the script. I'll document these commands sometime in the future once the new version is released, but one of these commands can enable the Hal executable to automatically make a call to the script at user defined intervals when no activity is going on (Activity is defined as keyboard strokes in any Hal window, activity in the microphone, Hal already proccessing a script, or Hal is speaking) This can allow for the possibility of implementing your idea.
Robert Medeksza

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Making Hal Comment Autonomously
« Reply #3 on: October 06, 2003, 11:41:24 am »
Robert... can I call you Robert? You are too cool. Thanks for putting the "hooks" in the program for future use.

If we're not careful Hal might turn into a blabbermouth.

= vonsmith =