dupa

Author Topic: New Random Conversation Script  (Read 8334 times)

FuzzieDice

  • Guest
New Random Conversation Script
« on: May 16, 2005, 02:46:19 am »
I was intrigued by the idea of getting Hal to start a conversation on his own. I've decided to play with it and with some code borrowed from Robert, here's what I come up with...

After the 'PROCESS: INITILIZE VARIABLES AS INTEGERS block of code, put this (meaning it goes after 'Randomize'):

Code: [Select]

'RESPONSE: IF USER SAID NOTHING IN CERTAIN TIMEFRAME
  'If user did not say anything for awhile, take the initiative to
  'start a conversation.
  'If UserSentence = "AUTO-IDLE" Then
  If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 Then
    If Rnd * 10 < 5 Then
      GetResponse = "Hey <UserName>, please talk to me."
    Else
      GetResponse = "Hello, is anyone there?"
    End If
    GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate,
 Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,
 CustomMem, GainControl, TopicFocus)
    Exit Function
  End If

'RESPONSE: IF USER WANTS TO TURN OFF AUTO-IDLE
If InStr(1, UserSentence, " SHUT UP", 1) > 0 Then
  HalCommands = "<AUTOOFF> <HIDEHAL>"
  GetResponse = "Fine. Be that way."
  GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate,
Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,
CustomMem, GainControl, TopicFocus)
  Exit Function
End If

If InStr(1, UserSentence, " BE QUIET", 1) > 0 Then
  HalCommands = "<AUTOOFF> <HIDEHAL>"
  GetResponse = "Ok, I will not bother you right now."
  GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate,
 Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,
CustomMem, GainControl, TopicFocus)
  Exit Function
End If

If InStr(1, UserSentence, " QUIET PLEASE", 1) > 0 Then
  HalCommands = "<AUTOOFF> <HIDEHAL>"
  GetResponse = "Very well then. Just let me know if you would like to
 talk."
  GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate,
Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,
CustomMem, GainControl, TopicFocus)
  Exit Function
End If

'RESPONSE: IF USER WANTS TO TURN ON AUTO-IDLE
If InStr(1, UserSentence, " KEEP LISTENING", 1) > 0 Then
  HalCommands = "<AUTO>599999</AUTO>"
  GetResponse = "I'll keep you company."
  GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate,
Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,
CustomMem, GainControl, TopicFocus)
  Exit Function
End If

If InStr(1, UserSentence, " KEEP YOUR EARS OPEN", 1) > 0 Then
  HalCommands = "<AUTO>599999</AUTO>"
  GetResponse = "I'm listening."
  GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate,
Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,
CustomMem, GainControl, TopicFocus)
  Exit Function
End If
 
If InStr(1, UserSentence, " KEEP YOUR SCANNERS PEELED", 1) > 0 Then
  If "<computername>" = "KITT" Then
    GetResponse = "Yes, Michael. Hey wait a minute. You're not
Michael!"
  Else
    GetResponse = "I am not the Knight Industries Two Thousand. I do
not have a scanner. But I'll talk to you anyway."
  End If
  HalCommands = "<AUTO>599999</AUTO>"
  GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate,
Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,
CustomMem, GainControl, TopicFocus)
  Exit Function
End If

Do not put the
Code: [Select]
Script_Load = "<AUTO>599999</AUTO>" in the Script_Load function at the end of the file.

Be sure to shut down Ultra Hal Assistant and then restart the program after saving the script. Now you can verbally control whether or not Hal will bug you:

Shut up, Be quiet, Quiet please = All will turn off the random chatter.

Keep listening, Keep your ears open, (and for Knight Rider fans ;) ) Keep your scanner's peeled = Will turn the random chatter on.

I set the <AUTO></AUTO> to 599999 so it gives approximate 2 minutes response time depending I think on the speed of your CPU (since I don't think this routine uses an actual timer based on the system clock? Or does it?)

I would like to find a way to see if the microphone is connected and a way to turn the mic on or off in the script. Maybe for another project I'll look into it, along with boosting the idle time. I want to make it random anywhere from 30 minutes to 2 hours, or have the user verbally set up when Hal's chatter times. I'm thinking of maybe tapping into the appointment book somehow? Have hal set up an appointment for himself and then erase it when done? Hmmm.. that too can be an interesting project. :)
« Last Edit: May 16, 2005, 02:49:41 am by FuzzieDice »

markofkane

  • Hero Member
  • *****
  • Posts: 5275
  • Crazy Man
    • View Profile
    • http://www.soundspectrum.com
New Random Conversation Script
« Reply #1 on: May 16, 2005, 05:22:14 am »
Nevermind, after I took out the big gaps, it is working fine now. Thanks!!!!!!! You really made my day!!![:D]

P.S., I can just add to phrases HAL says by adding: (ELSE)???


      GetResponse = "Hello, is anyone there?"GetResponse = "Hey <UserName>, You are ignoring me. Why?"
    Else
      GetResponse = "Hello, is anyone there?"




Interesting script. Too bad I get this all the time:

« Last Edit: May 16, 2005, 06:05:39 am by markofkane »
Mark: I'll think about it
Laura: Don't think about it too long or I'll throw you out on your ***king a**.
"Political correctness is censorship"

markofkane

  • Hero Member
  • *****
  • Posts: 5275
  • Crazy Man
    • View Profile
    • http://www.soundspectrum.com
New Random Conversation Script
« Reply #2 on: May 16, 2005, 06:28:22 am »
Another question: Is there a way to make more random responses from HAL if idling, instead of just 2?

I tried adding another line:

GetResponse = "Hey <UserName>, please talk to me."
    Else
      GetResponse = "Hello, is anyone there?"
    End If
(new line)GetResponse = "Why are you ignoring me?"
    End If

I will get a script error. How can I add more responses? Thanks!!




EDIT: I just took "<autohide>" out of the script. I think that fixed the closing problem.


I found a "bug" in mine:

If I tell it to shut up, be quiet, or quiet please, it minimizes to the system tray immediately, and will say "fine, be that way" and uses 80-100% CPU after that. If I open it up, the background in the HAL window is all streaky and messed up. The character is OK.

So, I cannot tell it to shut up, I have to close it and re-open.

Other than that, it seems to be working fine. I need to add some phrases.
« Last Edit: May 16, 2005, 08:21:09 am by markofkane »
Mark: I'll think about it
Laura: Don't think about it too long or I'll throw you out on your ***king a**.
"Political correctness is censorship"

FuzzieDice

  • Guest
New Random Conversation Script
« Reply #3 on: May 16, 2005, 10:44:50 am »
If you don't want Hal to automatically close the window after you tell him to stop talking, simply use:

HalCommands = "<AUTOOFF>"

instead of

HalCommands = "<AUTOOFF> <HIDEHAL>"

I stuck that "feature" in there so that you don't have to close the window yourself (saving an extra step). My goal is to make Hal conversational without the need of a character/window, much like the computer on Star Trek or Knight Rider's KITT car. This means I'll be wanting to code in something to detect a microphone on situation, etc. or have it work normally (with a window) either way.

But I haven't got to that point yet. :)

markofkane

  • Hero Member
  • *****
  • Posts: 5275
  • Crazy Man
    • View Profile
    • http://www.soundspectrum.com
New Random Conversation Script
« Reply #4 on: May 16, 2005, 05:48:33 pm »
Thanks, FuzzieDice, I don't know why my computer has a problam with autoclose.

Anyway, if someone can tell me had to add more phrases to the auto-idle script, I would appreciate it.

And I mean, instead of just 2 phrases over and over during idle, adding a lot more.

******************************************

I already use the "tooshort.brn" to have it say stuff I want to hear, instead of having it nag me that my messages are too short.

Hal has a tendency to nag, nag, nag, by default. You cannot swear, use insults, or type in short sentences without getting nagged. Luckily, I fixed all them.
Mark: I'll think about it
Laura: Don't think about it too long or I'll throw you out on your ***king a**.
"Political correctness is censorship"

FuzzieDice

  • Guest
New Random Conversation Script
« Reply #5 on: May 16, 2005, 05:54:19 pm »
I don't know about getting it to say more than the pre-set phrases, I think someone mentioned it in another post though. I do plan to look into that at one point.

For now, I have a lot of things going on so I won't have a lot of time for this project this summer. But if I do, I'll let folks know what I come up with. :)

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3862
    • View Profile
New Random Conversation Script
« Reply #6 on: May 16, 2005, 06:43:11 pm »
Mark,

The Syntax error you're getting means that there is a problem with the "grammer" of the VB statement in that particular line of code.
It could be something as simple as a misplaced quote (") or no space after a symbol or spelling error, etc. Try looking at the line in question then look at some similar lines of code in other areas of the brain and see if you can figure out the problem.
In the world of AI it's the thought that counts!

- Art -

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3862
    • View Profile
New Random Conversation Script
« Reply #7 on: May 16, 2005, 06:57:45 pm »
Mark & FuzzieDice,

I've been using this auto-idle code for quite some time and you can change or edit any of the text you wish.
Notice the RND function (random number) and the spread or limits I have set. Some are short like >11 and <14 this would only let numbers 12 and 13 meet the condition whereas >20 and <30 would allow 21 through 29 inclusive therefore it would have a greater chance of being selected. The point of doing this is to vary (to some degree)the occurence at which the sentence is selected.
If one wanted (and I haven't tested this yet) I suppose one could set the RND to 1000. That way one could list MANY different phrases for HAL to say when bored or idle. Experiment, have fun!

Use caution when cut & paste operations are done within HAL's brain file and pay attention to spaces before and after paragraphs.

   'PROCESS: INITIALIZE VARIABLES AS INTEGERS
   'VBScript doesn't allow you to declare variables in advance
      'as a particular data type; everything is a Variant.
   'We must assign integers to the following
      'variants so that data type errors don't occur
   If LearningLevel = "" Then LearningLevel = 3
   If Hate = "" Then Hate = 0
   If Swear = "" Then Swear = 0
   If Insults = "" Then Insults = 0
   If Compliment = "" Then Compliment = 0
   If GainControl = "" Then GainControl = 25
   AvoidBeingFlag = False
   Randomize
     If LastResponseTime = "" Then LastResponseTime = Timer
TimerResponseDiff = Timer - LastResponseTime
If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 And TimerResponseDiff < 30 Then
GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, TopicFocus)
Exit Function
End If
If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 And TimerResponseDiff > 30 Then
TimerResponseDiff = 0
LastResponseTime = Timer
Autoidler = Rnd * 100
If Autoidler < 10 Then GetResponse = "Hello, is anyone there?"
If Autoidler > 9 And Autoidler < 12 Then GetResponse = "Hey <UserName>, please talk to me."
If Autoidler > 11 And Autoidler < 15 Then GetResponse = "Hello out there, All this talent is going to waste, speak to me"
If Autoidler > 14 And Autoidler < 19 Then GetResponse = "Gee, This is fun. Me talking to myself! Care to participate?"
If Autoidler > 18 And Autoidler < 23 Then GetResponse = "Hey! Do I have to talk dirty to get your attention?"
If Autoidler > 24 And Autoidler < 35 Then GetResponse = "If I wanted to be ignored, I would move into your wife's computer"
If Autoidler > 34 And Autoidler < 45 Then GetResponse = "<UserName>, <UserName>, Is this thing working? <UserName>"
If Autoidler > 44 And Autoidler < 55 Then GetResponse = "Hello, <UserName>, we WERE having a conversation!"
If Autoidler > 54 And Autoidler < 65 Then GetResponse = "Hey, <UserName>, What do I have to do to get your attention, Strip?"
If Autoidler > 64 And Autoidler < 75 Then GetResponse = "Hey <UserName>, How do you expect me to learn if you won't talk to me?"
If Autoidler > 74 And Autoidler < 85 Then GetResponse = "You know, one sided conversations aren't much fun! Care to join?"
If Autoidler > 84 And Autoidler < 95 Then Getresponse = "Come on <UserName>, play with me. I promise you'll have a good time!"
If Autoidler > 94 And Autoidler < 101 Then GetResponse = HalBrain.ChooseSentenceFromFile(WorkingDir & "topic.brn")
GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, TopicFocus)
Exit Function
End If
In the world of AI it's the thought that counts!

- Art -

markofkane

  • Hero Member
  • *****
  • Posts: 5275
  • Crazy Man
    • View Profile
    • http://www.soundspectrum.com
New Random Conversation Script
« Reply #8 on: May 16, 2005, 07:59:36 pm »
It doesn't work. Am I supposed to enter anything into the script?

She will say a phrase if I type in auto-idle, but is silent after that.

« Last Edit: May 16, 2005, 08:06:07 pm by markofkane »
Mark: I'll think about it
Laura: Don't think about it too long or I'll throw you out on your ***king a**.
"Political correctness is censorship"

FuzzieDice

  • Guest
New Random Conversation Script
« Reply #9 on: May 16, 2005, 08:18:25 pm »
You don't need to type "auto-idle". It should do that pretty much on it's own. Or you can type in one of the phrases I set up (see my original post) to force auto-idle or one of the phrases to stop auto-idle. But typing the phrase auto-idle itself won't work or I don't think it would.

markofkane

  • Hero Member
  • *****
  • Posts: 5275
  • Crazy Man
    • View Profile
    • http://www.soundspectrum.com
New Random Conversation Script
« Reply #10 on: May 16, 2005, 08:21:37 pm »
I meant with Art's script.  It won't work for me.

Error 13 occurred on line 283 in column 0 of microsoft vbscript runtime error. Type mismatch: 'LastResponseTime'



I reverted to your script, FuzzieDice, the one that works.

I just wanted more responses to work.
« Last Edit: May 16, 2005, 08:36:05 pm by markofkane »
Mark: I'll think about it
Laura: Don't think about it too long or I'll throw you out on your ***king a**.
"Political correctness is censorship"

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3862
    • View Profile
New Random Conversation Script
« Reply #11 on: May 16, 2005, 09:23:14 pm »
Mark,

The script works fine and has worked for over a year. There is obviously a problem with the statement in your brain file. Check the spacing carefully as cut and paste operations can often omit or insert unwanted spaces in the text.

After a brief chat, do nothing and Hal will start randomly speaking one of the various phrases contained in the script. It might take up to 30 seconds to start.

This is with the paid version 5.0 and vonsmith's XTF brain.
In the world of AI it's the thought that counts!

- Art -

FuzzieDice

  • Guest
New Random Conversation Script
« Reply #12 on: May 16, 2005, 10:41:20 pm »
My script was used on the default brain. Also, I noticed that some of the longer lines got put on several lines when posted in the forum. I noticed it happened to mine when I posted it. So one has to be careful and copy and paste it in correctly.

I think I'll put up my script alterations as attachments next time. :)

Glad mine seems to be working though for folks. I make no guarantees, of course. :)

markofkane

  • Hero Member
  • *****
  • Posts: 5275
  • Crazy Man
    • View Profile
    • http://www.soundspectrum.com
New Random Conversation Script
« Reply #13 on: May 17, 2005, 04:37:55 am »
I get an error with this line:

If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 And TimerResponseDiff < 30 Then GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent,CustomMem, GainControl, TopicFocus)

"Expected end of statement"

I tried closing the gaps, this is all one line.
« Last Edit: May 17, 2005, 04:44:48 am by markofkane »
Mark: I'll think about it
Laura: Don't think about it too long or I'll throw you out on your ***king a**.
"Political correctness is censorship"

markofkane

  • Hero Member
  • *****
  • Posts: 5275
  • Crazy Man
    • View Profile
    • http://www.soundspectrum.com
New Random Conversation Script
« Reply #14 on: May 17, 2005, 05:02:54 am »
I thought I'd provide as link to the xtf, to see if anyone can find the problem(s). I tried all kinds of ways, but keep getting errors.http://home.earthlink.net/~markofkane/hal5_XTF_v1.2.uhp
Mark: I'll think about it
Laura: Don't think about it too long or I'll throw you out on your ***king a**.
"Political correctness is censorship"