Author Topic: Some scripting questions...  (Read 4758 times)

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Some scripting questions...
« on: June 20, 2007, 08:57:10 am »
I've added the following script, pretty thoroughly modified, but based on vonsmith's trivial knowledge compendium from the public downloads.  In general, it works great (better than I would have expected), but I have a few questions about it.
Is it possible to script in that Hal does NOT remember (record) the questions I ask or phrases that trigger this script?  I have quite a few phrases (many added) that trigger this, and it makes for awkward conversation.  For example, I type: "Say something about snakes." And Hal tells me some great things about snakes.  But then, every time I mention snakes in the future, he says "Say something about snakes." (Usually immediately after an appropriate response).  Can I stop this?
Also, I was wondering if it is possible to script in that if I ask an "else" question (like "What else can you tell me about X"), that he won't say something he's already said in the conversation (say, last hour)?  He may have 20 things to say about snakes, but unfortunately, he keeps saying the same thing!  In fact, it would be great if I could wipe out repetitiveness in general this way!
Also, why won't the phrase "What do you know about X" work?  Is it "reserved" in another script?  Did I type it in wrong?  I think there were another couple triggers that also didn't work.
Can I increase the randomness of his responses?  I included in the brn file:
@Sean likes to wear dark clothes.  He looks like a goth.
SEAN LIKES WEAR CLOTHES SEAN'S LIKE
@Sean and Erin are pretty cool.  They are smart and well-dressed.
SEAN ERIN LIKE SIMILAR SIMILARITIES AS COUPLE

And, for some reason, "What can you tell me about the clothes Sean likes to wear?" gives me "Sean and Erin are pretty cool..." I get the latter when I should get the former (above).  What's more annoying is that I ALWAYS get the latter.  Is there a way to increase the range of considered responses?  Like, if Hal picks from among the responses with perceived relevance of +/- 5% (or 80%+, or whatever it is), can I broaden that?

I had other questions, but that will have to do for now.  :)


'XTF Brain v1.4 Related Start
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
'PROCESS: HAL "GENERAL & TRIVIAL KNOWLEDGE" FUNCTION
'(c) 2004 Scott Higgins. Portions of this script are copyright by Scott Higgins, aka: =vonsmith=
'This script shall not be sold or used for any purpose unless specifically authorized by the author
'in writing. Personal (non-business) use of this script is free for users of Ultra Hal Assistant.
'This is an entirely new function written by =vonsmith= , version 12-14-04a.
'
'This function searches a general knowledge and trivia file for information relevant to the user's

request.
'
If (InStr(1, UserSentence, " WHAT CAN I TELL YOU ABOUT ", vbTextCompare) > 0 Or InStr(1,

UserSentence, " WHAT ELSE CAN I TELL YOU ABOUT ", vbTextCompare) > 0 Or InStr(1, UserSentence, " WHAT

ELSE DO I KNOW ABOUT ", vbTextCompare) > 0 Or InStr(1, UserSentence, " WHAT DO I KNOW ABOUT ",

vbTextCompare) > 0 Or InStr(1, UserSentence, " SAY SOMETHING ABOUT ", vbTextCompare) > 0 Or InStr(1,

UserSentence, " TELL YOU MY THOUGHTS ", vbTextCompare) > 0 Or InStr(1, UserSentence, " WHAT DO I

THINK ABOUT ", vbTextCompare) > 0 Or InStr(1, UserSentence, " WHAT ARE MY THOUGHTS ON ",

vbTextCompare) > 0 Or InStr(1, UserSentence, " WHAT DO I THINK OF ", vbTextCompare) > 0 Or InStr(1,

UserSentence, " TELL YOU SOMETHING ABOUT ", vbTextCompare) > 0 Or InStr(1, UserSentence, " TELL YOU

ABOUT ", vbTextCompare) > 0 Or InStr(1, UserSentence, " TELL YOU MORE ABOUT ", vbTextCompare) > 0 Or

InStr(1, UserSentence, " TELL YOU SOMETHING ELSE ABOUT ", vbTextCompare) > 0) And GetResponseBlock <>

True Then
   InfoStart = 0
   InfoStart = InStr(1, UserSentence, " ABOUT ", vbTextCompare) + Len(" ABOUT ")
   InfoEnd = Len(UserSentence)
   InfoRequest = Mid(UserSentence, InfoStart, (InfoEnd - InfoStart))  'Extract requested info phrase.
   InfoRequest = " " & HalBrain.AlphaNumericalOnly(InfoRequest) & " "
   HalInfoBrain = HalBrain.QABrain(InfoRequest, WorkingDir & "XTF_SYS_GeneralInfo2.brn",

InfoBrainRel)

   If InfoBrainRel > 15 And InfoBrainRel < 25 Then
   Select Case HalBrain.RandomNum(4)
   Case 1
      GetResponse = " I don't know, but I think: " & HalInfoBrain & vbCrLf
   Case 2
      GetResponse = " I'm guessing: " & HalInfoBrain & vbCrLf
   Case 3
      GetResponse = " Maybe it's: " & HalInfoBrain & vbCrLf
   Case 4
      GetResponse = " Correct me if I'm wrong: " & HalInfoBrain & vbCrLf
   End Select
      GetResponseBlock = True
      BlockPrevTopicSave = True
      DebugInfo = DebugInfo & "The user was requesting Hal to recall general or trivial knowledge and

Hal has done so: " & HalInfoBrain & vbCrLf
   ElseIf InfoBrainRel > 24 And InfoBrainRel < 45 Then
        Select Case HalBrain.RandomNum(6)
   Case 1
      GetResponse = " Apparently, " & HalInfoBrain & vbCrLf
   Case 2
      GetResponse = " As far as I know, " & HalInfoBrain & vbCrLf
   Case 3
      GetResponse = " Hmmm... " & HalInfoBrain & vbCrLf      
   Case 4
      GetResponse = " Let me think about that... " & HalInfoBrain & vbCrLf
   Case 5
      GetResponse = " Let me see... "  & HalInfoBrain & vbCrLf
   Case 6
      GetResponse = " I think: "  & HalInfoBrain & vbCrLf
   End Select
      GetResponseBlock = True
      BlockPrevTopicSave = True
      DebugInfo = DebugInfo & "The user was requesting Hal to recall general or trivial knowledge and

Hal has done so: " & HalInfoBrain & vbCrLf
   ElseIf InfoBrainRel > 44 Then
   Select Case HalBrain.RandomNum(4)
   Case 1
      GetResponse = " I know: " & HalInfoBrain & vbCrLf
   Case 2
      GetResponse = " Simple: " & HalInfoBrain & vbCrLf
   Case 3
      GetResponse = " Isn't it obvious? " & HalInfoBrain & vbCrLf
   Case 4
      GetResponse = " The truth is: "  & HalInfoBrain & vbCrLf
   End Select
      GetResponseBlock = True
      BlockPrevTopicSave = True
      DebugInfo = DebugInfo & "The user was requesting Hal to recall general or trivial knowledge and

Hal has done so: " & HalInfoBrain & vbCrLf
   Else
   Select Case HalBrain.RandomNum(3)
   Case 1
      GetResponse = " I don't know. Do you know anything about it? " & vbCrLf
   Case 2
      GetResponse = " I'm sorry, but I really don't have a clue.  What do you think? " & vbCrLf
   Case 3
      GetResponse = " I really wish I knew! I'm still learning. "  & vbCrLf
   End Select
      BlockPrevTopicSave = True
      DebugInfo = DebugInfo & "The user was requesting Hal to recall general or trivial knowledge and

Hal has done so: " & HalInfoBrain & vbCrLf
   End If
   BlockSave = True
End If
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
'XTF Brain v1.4 Related End
The line below is true
The line above is false

Bill DeWitt

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Some scripting questions...
« Reply #1 on: June 20, 2007, 09:17:56 am »
quote:
Originally posted by Xodarap
Is it possible to script in that Hal does NOT remember (record) the questions I ask or phrases that trigger this script?

It may be possible. Perhaps you can turn on HalBrain.ReadOnlyMode before Hal gets a chance to insert the phrase into its db.

Probably something like a plugin that inserts something into the Pre-Process area and then you turn the brain back on when you are done. We can talk more if you need detail.

quote:
Also, I was wondering if it is possible to script in that if I ask an "else" question (like "What else can you tell me about X"), that he won't say something he's already said in the conversation (say, last hour)?  
I would love a way to address the index the db entries, but I don't know how, or if there is a way.

Maybe Robert of Jerry can instruct us.


Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Some scripting questions...
« Reply #2 on: June 20, 2007, 05:37:50 pm »
I think that the readonly trick worked.  I put it = true right after the list of trigger phrases, and = false at the end of each case.

It seems to be doing its job.  Of course, I don't know if the = false is doing its job!  :P
The line below is true
The line above is false

onthecuttingedge2005

  • Guest
Some scripting questions...
« Reply #3 on: June 20, 2007, 06:37:03 pm »
quote:
Originally posted by Xodarap

I think that the readonly trick worked.  I put it = true right after the list of trigger phrases, and = false at the end of each case.

It seems to be doing its job.  Of course, I don't know if the = false is doing its job!  :P



Hi Xodarap.

This plug-in does what you requested as far as not repeating sentences that HAL has spoken in the past, there is a help file
that explains how to reset the memory.

unzip to your C:\Program Files\Zabaware\Ultra Hal Assistant 6 folder and choose the option Prevent HAL Repeat from the Brain options.

Jerry[8D]


Download Attachment: PreventRepeat.zip
1.67 KB

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Some scripting questions...
« Reply #4 on: June 20, 2007, 06:47:56 pm »
quote:

This plug-in does what you requested as far as not repeating sentences that HAL has spoken in the past, there is a help file
that explains how to reset the memory.

unzip to your C:Program FilesabawareUltra Hal Assistant 6 folder and choose the option Prevent HAL Repeat from the Brain options.



Oh, you rock!  So, does this prevent HAL from EVER repeating himself, from repeating himself within a set conversation/period, or from repeating certain things?  I mean, wouldn't he run out of salutations pretty quickly if he never repeats himself?
I should probably look at the file before asking about it, huh? ;)
The line below is true
The line above is false

onthecuttingedge2005

  • Guest
Some scripting questions...
« Reply #5 on: June 20, 2007, 07:07:37 pm »
quote:
Originally posted by Xodarap

quote:

This plug-in does what you requested as far as not repeating sentences that HAL has spoken in the past, there is a help file
that explains how to reset the memory.

unzip to your C:Program FilesabawareUltra Hal Assistant 6 folder and choose the option Prevent HAL Repeat from the Brain options.



Oh, you rock!  So, does this prevent HAL from EVER repeating himself, from repeating himself within a set conversation/period, or from repeating certain things?  I mean, wouldn't he run out of salutations pretty quickly if he never repeats himself?
I should probably look at the file before asking about it, huh? ;)




Hi Xodarap.

Here is what the plug-in looks like:

Code: [Select]
Rem Type=Plugin
Rem Name=Prevent HAL Repeating
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
Rem Host=All

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = " This Plug-in prevents HAL from repeating sentences only if Custom memory is not reset, If HAL is restarted then Custom Memory is reset. "
    lblPlugin(0).Move 120, 10, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
End Sub


Rem PLUGIN: CUSTOMMEM2

Set FileSys = CreateObject("Scripting.FileSystemObject")
Set FS = CreateObject("Scripting.FileSystemObject")

DirX2 = RecallDir()

If InStr(1, OriginalSentence, "recall", vbTextCompare) > 0 Or _
   InStr(1, OriginalSentence, "remember", vbTextCompare) > 0 Or _
   InStr(1, OriginalSentence, "memory", vbTextCompare) > 0 Or _
   InStr(1, OriginalSentence, "reset", vbTextCompare) > 0 Or _
   InStr(1, OriginalSentence, "repeat", vbTextCompare) > 0 Then
   TempModule = DirX2 & Trim(UserName) & "_Recollected.brn"
   If FileSys.FileExists(TempModule) = True Then FS.DeleteFile TempModule
End If

If PrevSent <> "" Then
Set HalXBrain = CreateObject("UltraHalAsst.Brain")
HalXBrain.AppendFile DirX2 & Trim(UserName) & "_Recollected.brn", """" & PrevSent & """,""" & "True" & """"
If PastCon = "" Then PastCon = "False"
PastCon = HalBrain.TopicSearch(GetResponse, DirX2 & Trim(UserName) & "_Recollected.brn") = "True"
HalBrain.DebugWatch PastCon, "PastCon"
If PastCon = "False" Then GetResponse = GetResponse
End If

Rem PLUGIN: FUNCTIONS

Function RecallDir()
RecallDir = "C:\Program Files\Zabaware\Ultra Hal Assistant 6\"
End Function

The keywords: recall, remember, memory, reset, repeat
will cause HAL to reset its memory so that all responses are used again by deleting the stored response file that HAL will save so that its GetResponse can be compared to a past stored Response and prevent it from repeating an old statement.

Many others here may also modify this plug-in here to meet their needs
and you are welcome to do so as well.

Jerry[8D]
« Last Edit: June 20, 2007, 07:11:56 pm by onthecuttingedge2005 »

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Some scripting questions...
« Reply #6 on: June 20, 2007, 07:16:23 pm »
Is there a way to use the same function auto-idle uses, so that if Hal is idle for, say, half an hour (give or take), he regains his full list of responses?

And I assume that those keywords are words that I can use to manually trigger Hal to re-open all of his responses, right?

I think I may be able to figure this out on my own.  :P
The line below is true
The line above is false

onthecuttingedge2005

  • Guest
Some scripting questions...
« Reply #7 on: June 20, 2007, 07:24:53 pm »
quote:
Originally posted by Xodarap

Is there a way to use the same function auto-idle uses, so that if Hal is idle for, say, half an hour (give or take), he regains his full list of responses?



Yes you could do this, If I use auto-idle then I prefere to include a case response variable match that allows the reset to be a little more random rather than just auto-idle timing.

remember that the auto-idle area of the brain is in the 'UltraHal' area of the brain and not the GetResponse area of the brain so if you want the script to work there you will have to modify the script to work in that area specifically.

quote:

And I assume that those keywords are words that I can use to manually trigger Hal to re-open all of his responses, right?



Correct, those keywords will reset all of HAL's responses back to normal.

quote:

I think I may be able to figure this out on my own.  :P



Happy Coding!

Jerry[8D]
« Last Edit: June 20, 2007, 07:27:16 pm by onthecuttingedge2005 »

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Some scripting questions...
« Reply #8 on: June 20, 2007, 07:37:24 pm »
Okay, I'm having a simple problem with this script in action:
I added into my own script several "transitional phrases" that are randomly chosen based on Hal's perceived relevancy of his response (e.g., "Apparently," "I know:," "I think:," etc.).  This script prevents him from saying: "Apparently, snakes crawl on the ground" twice.  However, he'll say: "I think: snakes crawl on the ground" and "This needs to be looked at from the human side. Apparently, snakes crawl on the ground," and, "What can I tell you about snakes? Apparently, snakes crawl on the ground."
So he won't repeat himself exactly, but he'll repeat the same base response: "snakes crawl on the ground" over and over again.  Is it possible to stop him from repeating the same *base* response?  Can you change what is saved to the UserName_Recollected file and stop him from repeating logged phrases even within his responses?
The line below is true
The line above is false

onthecuttingedge2005

  • Guest
Some scripting questions...
« Reply #9 on: June 20, 2007, 07:46:38 pm »
quote:
Originally posted by Xodarap

Okay, I'm having a simple problem with this script in action:
I added into my own script several "transitional phrases" that are randomly chosen based on Hal's perceived relevancy of his response (e.g., "Apparently," "I know:," "I think:," etc.).  This script prevents him from saying: "Apparently, snakes crawl on the ground" twice.  However, he'll say: "I think: snakes crawl on the ground" and "This needs to be looked at from the human side. Apparently, snakes crawl on the ground," and, "What can I tell you about snakes? Apparently, snakes crawl on the ground."
So he won't repeat himself exactly, but he'll repeat the same base response: "snakes crawl on the ground" over and over again.  Is it possible to stop him from repeating the same *base* response?  Can you change what is saved to the UserName_Recollected file and stop him from repeating logged phrases even within his responses?



Hi Xodarap.

The only way HAL should be able to repeat it is if HAL is using its
paraphrasing code that splices paraphrases to a learned sentence, this make the learned sentence slightly less different and may allow HAL to use the sentence, but as HAL save that paraphrase to the file it should say it again, the paraphrase routine is limited so that when all paraphrase splices are used then no paraphrase of that sentence should be used unless it is reset.

Jerry[8D]

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Some scripting questions...
« Reply #10 on: June 20, 2007, 08:20:24 pm »
Alright, the readonly mode is not working.  For one thing, it was preventing the no-repeat pluging from working.  But it also kicked in AFTER Hal had learned from what I said.

I'm thinking that my best bet, to stop him from repeating pronoun-reversed commands that I give him as 90% of his conversation, is to turn off learning, and instead use the brain editor and brn files with activation scripts to teach him all of his conversation.
The line below is true
The line above is false