Author Topic: Hal 5 to Hal 6 - .brn to Plugin help?  (Read 3842 times)

Zaphod

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Hal 5 to Hal 6 - .brn to Plugin help?
« on: June 10, 2010, 10:28:58 am »
I used Hal 5 for a few years and enjoyed it immensely. A few months ago I finally splurged and purchased Hal 6.2.  I find that since purchasing Hal, I talk to him less and less, and I think I've figured out why - I'm missing quite a few of the functions that I had grown used to with version 5 - They're just not there in version 6.2 because of the change from .brn files to the Plugin system.

I know I can switch to the old vonSmith XTF Brain, but then I lose all the other functionality of the new Hal...

So, I'm wondering if some of the older "additions" could be converted to work with the new Hal?

Here are the ones I'm most interested in. Please forgive me for the length of the post, and also if I have not credited (or mis-credited) the author(s), as I was sloppy in the old days and didn't always copy everything...

Author: vonSmith (From his XTF Brain)
Name: Capitalize

Code: [Select]
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
'ADDITIONAL CAPABILITIES:
'Normally Hal converts every user input into all caps to evaluate the sentence
'and create a response. However if Hal parrots back the user input the user's
'capitalization is lost. Example:
'  User: Where is Disneyland?  Hal: Where is disneyland? We must examine this.
'Capitals in names of people and places are lost similarly.
'  User: Do you know Ted and Mark?  Hal: Should I know ted and mark?
'The programmer could edit the XTF_SYS_Corrections.brn file to substitute Mark for mark
'in all cases, but this would erroneously lead to:
'  User: How much should I fill a glass?  Hal: Fill it to the Mark.
'
'This rewritten function will preserve the user's capitalized words in the input
'sentence and replace Hal's uncapitalized words in GetResponse with the correct
'user capitalized versions. Example:
'  User: Where is Ted and Mark?  Hal: I don't know Ted and Mark.
'Hal now takes a clue from the user about capitalization.
'  User: Where is Ted's mark?  Hal: Ted's mark is not here.
'  User: I know ted and mark.  Hal: Where is ted and mark.
'
'In cases where the user always wants a word capitalized, then Hal can save a
'word to the XTF_SYS_Corrections.brn for the user. Example:
'  User: Hal capitalize Disneyland.
'  Hal: Your input Disneyland is saved as capitalized in the XTF_SYS_Corrections.brn file.
'The first word in the command must be Hal's name. If your Hal is named Betty then type
'  User: Betty capitalize Disneyland.
'Now for an example:
'  User: I hear Saint Mary's bells.  Hal: What is Saint Mary's bells?
'However Hal still takes a clue from the user's input.
'  User: I hear saint mary's bells.  Hal: What is saint mary's bells?
'The phrase "saint mary's" is still lower case even if it is in the XTF_SYS_Corrections.brn
'file. Hal always assumes the user's use of capitalization is correct.
'This method should produce the correct capitalization in almost every case. The
'programmer shouldn't add words like "Mark" or "Hall" to XTF_SYS_Corrections.brn because
'these names can also be used as uncapitalized words. However words like "Fred",
'"God", "Christmas", "Knott's Berry Farm" can be added with reasonable certainty
'that they should always be capitalized. You can add as many words to
'XTF_SYS_Corrections.brn as you like. Duplicated words will not be added to the file.
'
'This function does not handle all capitalized words like acronyms, i.e., DOA, SUV.
'Unfortunately Hal's other functions do not preserve all cap words during the final
'processing of GetResponse.
'
'Have fun with this improved function. =vonsmith=
'
'P.S. - Try this. User: Where is Mark's mark? See if Hal gets it right.
'
Dim UserCapRequest, CapWordPos
'Check to see if the user wants to add a word or phrase to the XTF_SYS_Corrections.brn file.
UserCapRequest = False
CapWordPos = 0
If InStr(1, UserSentence, ComputerName & " ALWAYS CAPITALIZE " , vbTextCompare) > 0 Then
   UserCapRequest = True
   CapWordPos = 3
ElseIf InStr(1, UserSentence, ComputerName & " CAPITALIZE " , vbTextCompare) > 0 Then
   UserCapRequest = True
   CapWordPos = 2
ElseIf InStr(1, UserSentence, ComputerName & " CAPS " , vbTextCompare) > 0 Then
   UserCapRequest = True
   CapWordPos = 2
ElseIf InStr(1, UserSentence, ComputerName & " CAP " , vbTextCompare) > 0 Then
   UserCapRequest = True
   CapWordPos = 2
End If

If UserCapRequest = True And CapWordPos > 0 Then
   BlockSave = True
   GetResponseBlock = True
End If
'NOTE: This information will be further processed in Part II of this function.
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x





'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
'Capitalization Part II

Dim CapWordArray, CapsWord(50), CapArraySize
CapArraySize = 0
CapWordArray = Split(Trim(OriginalSentence), " ", -1, 1)  'WordArray() contains each word in sentence.
If (IsArray(CapWordArray) = True And UBound(CapWordArray) > -1) Then CapArraySize = UBound(CapWordArray)
If CapArraySize > 50 Then CapArraySize = 50  'Limit array size to something manageable.
'Check all words in the user's input and preserve capitalized words in the CapsWord() array.
'Variable 'I' starts at 1 instead of zero and thus ignores the first word in the sentence
' since that will always be capitalized.
CapsCnt = 0
For I = 1 To CapArraySize
   CapWordArray(I) = HalBrain.AlphaNumericalOnly(Trim(CapWordArray(I)))
   LeftChar = Left(CapWordArray(I), 1)
   If Len(LeftChar) = 0 Then LeftChar = " "
   If (Asc(LeftChar) > 64 And Asc(LeftChar) < 91) Then  'Check if first letter is capitalized.
      CapsCnt = CapsCnt + 1
      CapsWord(CapsCnt) = CapWordArray(I)
   End If
Next

'Save capitalization request from user. The user request is detected in Part I of this function.
If UserCapRequest = True And CapWordPos > 0 Then
   CapPhrase = ""
   For I = CapWordPos To CapArraySize  'Format word or phrase.
      CapPhrase = CapPhrase & " " & CapWordArray(I)
   Next
   CapPhrase = Trim(CapPhrase)
   'Check and see if capitalized word has been saved to XTF_SYS_Corrections.brn before. Only save if doesn't exist there.
   If HalBrain.TopicSearch(" " & LCase(CapPhrase) & " ", WorkingDir & "XTF_SYS_Corrections.brn") <> " " & CapPhrase & " " Then
      HalBrain.AppendFile WorkingDir & "XTF_SYS_Corrections.brn", """" & " " & LCase(CapPhrase) & " " & """,""" & " " & CapPhrase & " " & """" & VbCrLf & """" & " " & LCase(CapPhrase) & "'" & """,""" & " " & CapPhrase & "'" & """"
   End If
   GetResponse = " I'll remember to capitalize <quote>" & CapPhrase & "<quote> in the future. " & GetResponse
'   GetResponseBlock = True
End If
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
Author: vonSmith (From his XTF Brain)
Name: Hal calls user by Nickname

Code: [Select]
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
'PROCESS: HAL CALLS USER BY NICKNAME - PART I OF II
'(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 11-19-03a.
'Replaces version 11-14-03a. This newer version varies the nickname a bit more if
'"<UserName>" occurs more than once in the GetResponse string.
'
'This is the first part of this function. The second part is located toward the end of
'this script. This function lets the user specify one or more nicknames that the user wishes
'to be called by Hal. The nicknames are stored in a user specific self generated file
'called XTF_SYS_UserNickname(UserName).brn. If more than one nickname is specified then Hal
'will randomly choose one of the nicknames from the XTF_SYS_UserNickname(UserName).brn file.
'This is nice if you want Hal to call you "Master" sometimes and at other times "Great One".
'Multiple nicknames are great for creating petnames such as "sweetie", "honey", "dearest", etc.
'If a nickname Is specified Then the default Hal Assistant username will no longer be used
'when Hal speaks to the user, however the default username is still used for assigning
'user filenames and all other normal Hal functions. If the user wants to be called by
'his/her default Hal Assistant username then just add it as a nickname. If the user
'prefers to be called one nickname more often than another then just add that nickname
'multiple times. The more times the user adds a nickname the more likely that nickname
'will be used. The function does not affect any other Hal brain operations or files.
'To get rid of the nicknames delete the XTF_SYS_<UserName>UserNickname.brn file.

'This function is triggered by the flag "QuestionPending" set by
'the lower part of this function.

'Declare variables.
Dim NickArray, Nickname, NickStart, NickDetect
'Service user's request for a nickname.
If QuestionPending = "HAL CALLS USER BY NICKNAME" And Nickname <> "" Then
   'Did user say "Yes", "No" or ""
   YesOrNo = YesNoEval(UserSentence, WorkingDir)

   If YesOrNo = "YES" Then
      If Nickname <> "" And LearningLevel > 1 Then
         HalBrain.AppendFile WorkingDir & "XTF_SYS_UserNickname(" & Trim(UserName) & ").brn", Nickname & VbCrLf & Nickname
      End If
      Select Case Int(Rnd * 6) + 1
         Case 1
            GetResponse = "<UserName>! I'll remember your nickname <quote>" & Nickname & "<quote>. "
         Case 2
            GetResponse = "Okay, I'll add your nickname <quote>" & Nickname & "<quote> to my list of things to remember. "
         Case 3
            GetResponse = "Okay, I'll call you <quote>" & Nickname & "<quote> as a nickname. "
         Case 4
            GetResponse = "<quote>" & Nickname & "<quote> is an interesting nickname, I'll remember it. "
         Case 5
            GetResponse = "<UserName>, I'll remember your nickname. "
         Case 6
            GetResponse = "I'll make a point of remembering your nickname. "
      End Select
   ElseIf YesOrNo = "NO" Then
      Select Case Int(Rnd * 4) + 1
         Case 1
            GetResponse = "Okay, I'll just forget about it for now. "
         Case 2
            GetResponse = "Okay, I won't worry about it. "
         Case 3
            GetResponse = "Okay <UserName>, not a problem. "
         Case 4
            GetResponse = "I'll forget about it then. "
      End Select
   Else
      GetResponse = "I'm not sure I understand. I'll take that to mean no. "
   End If

   QuestionPending = ""  'Reset the QuestionPending variable.
   BlockSave = True  'Block the saving of the user's YES/NO answer.
End If

'Detect user's request for a nickname.
If InStr(1, UserSentence, " NICKNAME", 1) > 0 Or InStr(1, UserSentence, " NICK NAME", 1) > 0 And QuestionPending = "" And GetResponseBlock <> True Then
   TestSentence = " " & UCase(Trim(HalBrain.AlphaNumericalOnly(OriginalSentence))) & " "
   While InStr(1, TestSentence, "  ", vbTextCompare) > 0
      TestSentence = Replace(TestSentence, "  ", " ", 1, -1, vbTextCompare) 'Replace multiple spaces with single spaces.
   Wend

   'Initalize variables.
   Nickname = ""
   NickStart = 0
   NickDetect = 0

   'Typical user phrases detected by this function:
   ' MY NICKNAME IS nickname.
   ' REMEMBER MY NICKNAME nickname.
   ' ONE OF MY NICKNAMES IS nickname.
   ' USE MY NICKNAME nickname.
   ' CALL ME BY MY NICKNAME nickname.
   ' CALL ME BY THE NICKNAME nickname.
   
   'Detect user comment.
   NickDetect = InStr(1, TestSentence, " MY NICKNAME IS ", vbTextCompare)
   NickStart = NickDetect + Len(" MY NICKNAME IS ")
   If NickDetect = 0 Then
      NickDetect = InStr(1, TestSentence, " MY NICK NAME IS ", vbTextCompare)
      NickStart = NickDetect + Len(" MY NICK NAME IS ")
   End If
   If NickDetect = 0 Then
      NickDetect = InStr(1, TestSentence, " MY NICKNAMES IS ", vbTextCompare)
      NickStart = NickDetect + Len(" MY NICKNAMES IS ")
   End If
   If NickDetect = 0 Then
      NickDetect = InStr(1, TestSentence, " MY NICK NAMES IS ", vbTextCompare)
      NickStart = NickDetect + Len(" MY NICK NAMES IS ")
   End If
   If NickDetect = 0 Then
      NickDetect = InStr(1, TestSentence, " MY NICKNAME ", vbTextCompare)
      NickStart = NickDetect + Len(" MY NICKNAME ")
   End If
   If NickDetect = 0 Then
      NickDetect = InStr(1, TestSentence, " MY NICK NAME ", vbTextCompare)
      NickStart = NickDetect + Len(" MY NICK NAME ")
   End If
   If NickDetect = 0 Then
      NickDetect = InStr(1, TestSentence, " THE NICKNAME ", vbTextCompare)
      NickStart = NickDetect + Len(" THE NICKNAME ")
   End If
   If NickDetect = 0 Then
      NickDetect = InStr(1, TestSentence, " THE NICK NAME ", vbTextCompare)
      NickStart = NickDetect + Len(" THE NICK NAME ")
   End If
   
   If NickStart > 0 And NickStart < Len(TestSentence) Then  'If Nickname exists then extract it from the sentence.
      Nickname = Mid(TestSentence, NickStart, (Len(TestSentence) - NickStart))
      Nickname = Trim(Nickname)
   
      'Process the user's requested nickname for proper capitalization.
      If HalBrain.CountInstances(" ", Nickname) > 0 Then  'Is a multiple word nickname.
         NickArray = Split(Nickname, " ", -1, vbTextCompare)
         If (IsArray(NickArray) = True And UBound(NickArray) > -1) Then
            Nickname = ""
            For X = 0 To UBound(NickArray)
               LeftChar = Left(NickArray(X), 1)  
               If (Asc(LeftChar) > 64 And Asc(LeftChar) < 91) Then  'Check if first letter is capitalized.
                  'Make sure only the first letter is capitalized.
                  'If Nickname is all caps then Hal will make it all lowercase by default.
                  'If Nickname is already all lowercase then leave it alone.
                  Nickname = Nickname & " " & LeftChar & LCase(Mid(NickArray(X), 2, Len(NickArray(X))))  
               Else
                  Nickname = Nickname & " " & LCase(NickArray(X))
               End If
            Next
         End If
      Else  'Is a single word nickname.
         LeftChar = Left(Nickname, 1)  
         If (Asc(LeftChar) > 64 And Asc(LeftChar) < 91) Then  'Check if first letter is capitalized.
            'Make sure only the first letter is capitalized.
            'If Nickname is all caps then Hal will make it all lowercase by default.
            'If Nickname is already all lowercase then leave it alone.
            Nickname = LeftChar & LCase(Mid(Nickname, 2, Len(Nickname)))  
         End If
      End If
      Nickname = Trim(Nickname)

      Select Case Int(Rnd * 4) + 1
         Case 1
            GetResponse = "Is it alright if I call you <quote>" & Nickname & "<quote>? "
         Case 2
            GetResponse = "Should I call you <quote>" & Nickname & "<quote> sometimes? "
         Case 3
            GetResponse = "May I call you <quote>" & Nickname & "<quote> sometimes? "
         Case 4
            GetResponse = "Is it okay to call you <quote>" & Nickname & "<quote>? "
      End Select

      QuestionPending = "HAL CALLS USER BY NICKNAME" 'Triggers the "HAL CALLS USER BY NICKNAME" function above.
      BlockSave = True
      GetResponseBlock = True
   End If
End If
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x





'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
'In Ultra Hal Assistant v5.0 the "POST PROCESS: SAVE HAL'S RESPONSE"
' function should precede this function.
'
'PROCESS: HAL CALLS USER BY NICKNAME - PART II OF II
'(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 11-19-03a.
'Replaces version 11-14-03a. This newer version varies the nickname a bit more if
'"<UserName>" occurs more than once in the GetReponse string.
'
'This is the second part of this function. The first part is located toward the top of this script.
'This function lets the user specify one or more nicknames that the user wishes
'to be called by Hal. The nicknames are stored in a user specific self generated file
'called XTF_SYS_<UserName>UserNickname.brn. If more than one nickname is specified then Hal
'will randomly choose one of the nicknames from the XTF_SYS_<UserName>UserNickname.brn file.
'This is nice if you want Hal to call you "Master" sometimes and at other times "Great One".
'Multiple nicknames are great for creating petnames such as "sweetie", "honey", "dearest", etc.
'If a nickname Is specified Then the default Hal Assistant username will no longer be used
'when Hal speaks to the user, however the default username is still used for assigning
'user filenames and all other normal Hal functions. If the user wants to be called by
'his/her default Hal Assistant username then just add it as a nickname. If the user
'prefers to be called one nickname more often than another then just add that nickname
'multiple times. The more times the user adds a nickname the more likely that nickname
'will be used. The function does not affect any other Hal brain operations or files.
'To get rid of the nicknames delete the XTF_SYS_<UserName>UserNickname.brn file.
Dim PrevNickname, UserNickname
PrevNickname = ""
UserNickname = ""
TestSentence = UserSentence
If InStr(1, GetResponse, "<UserName>", vbTextCompare) > 0 Then
   For X = 0 To 3
      UserNickname = HalBrain.ChooseSentenceFromFile(WorkingDir & "XTF_SYS_UserNickname(" & Trim(UserName) & ").brn")
'      If StrComp(PrevNickname, Nickname, vbTextCompare) = 0 Then 'If the same name as last time try to get another name.
      If UserNickname = PrevNickname Then  'If the same name as last time try to get another name.
         UserNickname = HalBrain.ChooseSentenceFromFile(WorkingDir & "XTF_SYS_UserNickname(" & Trim(UserName) & ").brn")
      End If
      If UserNickname <> "" Then GetResponse = Replace(GetResponse, "<UserName>", UserNickname, 1, 1, vbTextCompare)
      PrevNickname = UserNickname
   Next
   GetResponse = Replace(GetResponse, "<UserName>", UserNickname, 1, -1, vbTextCompare) 'Replace any remaining "<UserName>".
End If
'x=x=x=x=x=x=x=x==vonsmith==x=x=x=x=x=x=x=x=x
Author: Bill Rogers
Name: Quote

Code: [Select]
'x=x=x=x=x=x=x=x==billrogers=x=x=x=x=x=x=x=x=x
'RESPOND: TELL QUOTE AT USER'S REQUEST
'If the user asks Hal to tell a quote, Hal will do so on request.
    If HalBrain.TopicSearch(UserSentence, WorkingDir & "XTF_SYS_QuoteDetect.brn") = "True" And GetResponseBlock <> True Then
        GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile(WorkingDir & "XTF_SYS_Quote.brn")
        BlockSave = True  'Don't save User input when requesting a quote.
        DebugInfo = DebugInfo & "The user has requested Hal to tell a quote and Hal has done so: " & GetResponse & VbCrLf
    End If
Author: Me (Zaphod)
Name: On This Day

I posted this on the Forum http://www.zabaware.com/forum/topic.asp?TOPIC_ID=5294
Code: [Select]
'x=x=x=x=x=x=x=x=x=x==ZAPHOD==x=x=x=x=x=x=x=x=x=x
'RESPOND: "On This Day" request
'Upon user request, Hal will read several entries from a
'file with info on events from this date in history.
    DOM = right("0" & day(date()),2) 'Gives two-digit day of month.
    MON = right("0" & month(date()),2) 'Gives two-digit month.
    OTDDate = MON + DOM
    If HalBrain.TopicSearch(UserSentence, WorkingDir & "OnThisDayDetect.brn") = "True" And GetResponseBlock <> True Then
    Roulette = Int(Rnd*5)
        If Roulette = 1 Then GetResponse = "Okee Dokie. I'll fetch you an item right now!"
        If Roulette = 2 Then GetResponse = "Alrighty, how's about I get you two items?"
        If Roulette = 3 Then GetResponse = "Sure thing! Here's three items that correspond to today's date in history."
        If Roulette = 4 Then GetResponse = "Humph! Brain the size of a planet, and you want me to fetch trivia for you. Oh well..."
        If Roulette = 5 Then GetResponse = "Get ready, cuz here comes a whole mouth full!"
        BlockSave = True
    For x = 1 to Roulette
        GetResponse = GetResponse & HalBrain.ChooseSentenceFromFile(WorkingDir & "OTD\" & OTDDate + ".txt") + " ... "
        BlockSave = True  'Don't save User input when requesting a quote.
        DebugInfo = DebugInfo & "The user has requested an On This Day quote and Hal has done so: " & GetResponse & VbCrLf
    Next
    End If
'x=x=x=x=x=x=x=x=x=x==ZAPHOD==x=x=x=x=x=x=x=x=x=x
Author: onthecuttingedge2005
Name: Spelling Correction

Code: [Select]
' Here we can correct Hals spelling simply by telling him how to spell the incorrect word or phrase
' to the correct word or phrase he is suppose to say in its place.
'
' Example:
' User: have you ever went trick or treating?
' Hal: I ever went trick or treating? < incorrect phrase: I ever.
' the bot owner will then say in these exact words:
' I ever should be spelled have I ever.
' Hal will then tell you he has corrected himself.
'
' New Corrected Example:
' User: Have you ever went tricker treating?
' Hal: Have I ever went tricker treating?
'
' The method is to put only the incorrect word or phrase before the " should be spelled " and the correct
' response directly after the " should be spelled " because if you add any additional wording to your
' correcting statement, then Hal will add your verbage to the correction file - so be very direct when
' correcting Hal so he appends only the words or phrases you want corrected, split by the keyword
' " should be spelled ".
' The phrase " should be spelled " will not be appended to the correction file, only the incorrect and
' correct word or phrase will be appended if you follow these instructions correctly.

If InStr(OriginalSentence, " ") > 0 And InStr(1, OriginalSentence, " SHOULD BE SPELLED ", 1) > 0 Then
SentPieces = Split(OriginalSentence, " SHOULD BE SPELLED ", 2, vbTextCompare)
SubPhrase = Trim(SentPieces(0))
PredPhrase = Trim(SentPieces(1))
SubPhrase = HalBrain.AlphaNumericalOnly(SubPhrase)
PredPhrase = HalBrain.AlphaNumericalOnly(PredPhrase)
HalBrain.AppendFile WorkingDir & "corrections.brn", """" & SubPhrase & """,""" & PredPhrase & """"
GetResponse = PredPhrase & ", <-- I have made the correction, thank you." & vbCrLf
DebugInfo = DebugInfo & "Spelling has been corrected from: " & SubPhrase & "to" & PredPhrase & vbCrLf
Else
DebugInfo = DebugInfo & "Spelling has not been corrected from: " & SubPhrase & "to" & PredPhrase & vbCrLf
End If
'Best of wishes and grand new discoveries.
' Jerry
Author: Zaphod
Name: Repeat After Me

Code: [Select]
If InStr(1, OriginalSentence, ComputerName & ", REPEAT AFTER ME: " , 1) > 0 Then
BreakDown = Split(OriginalSentence, ", REPEAT AFTER ME: ", 2, vbTextCompare)
RepeatPhrase = Trim(BreakDown(1))
BlockSave = True
GetResponse = ""
HalCommands = "<SPEAK>" & RepeatPhrase & "</SPEAK>"
End If
Author: Zaphod
Name: Movie Info

(This one accesses a huge text file, "MyMovieInfo.txt" with the info from my movie collection, getting hits from the movie's Title)
Code: [Select]
If InStr(1, OriginalSentence, ComputerName & ", MOVIE INFO FOR " , 1) > 0 Then
    BreakDown = Split(OriginalSentence, ", MOVIE INFO FOR ", 2, vbTextCompare)
    MovieName = Trim(BreakDown(1))
    GetResponse = HalBrain.TopicSearch(MovieName, WorkingDir & "MyMovieInfo.txt")
    BlockSave = True
End If
Author: Zaphod
Name: Pick a Movie

(This also accesses the "MyMovieInfo.txt" file to pick a film at random)
Code: [Select]
If InStr(1, OriginalSentence, " PICK A MOVIE " , 1) > 0 Then
   BlockSave = True
Select Case (Int(Rnd * 7) + 1)
Case 1
   GetResponse = "Ooh, I've been wanting to see " & HalBrain.ChooseSentenceFromFile(WorkingDir & "MyMovieTitles.brn")
Case 2
   GetResponse = "How about " & HalBrain.ChooseSentenceFromFile(WorkingDir & "MyMovieTitles.brn")
Case 3
   GetResponse = "Hummm... I dunno... Maybe " & HalBrain.ChooseSentenceFromFile(WorkingDir & "MyMovieTitles.brn")
Case 4
   GetResponse = "Well, <UserName>, If I have to pick, I'll go with " & HalBrain.ChooseSentenceFromFile(WorkingDir & "MyMovieTitles.brn")
Case 5
   GetResponse = "Call me crazy, but I think we should watch " & HalBrain.ChooseSentenceFromFile(WorkingDir & "MyMovieTitles.brn")
Case 6
   GetResponse = HalBrain.ChooseSentenceFromFile(WorkingDir & "MyMovieTitles.brn") & " and it looks good."
Case 7
   GetResponse = "Didn't you say the other day that you wanted to see " & HalBrain.ChooseSentenceFromFile(WorkingDir & "MyMovieTitles.brn")
End Select
   DebugInfo = DebugInfo & "The user has asked Hal to choose a movie to watch and Hal has done so: " & GetResponse & vbCrLf
End If
Author: Zaphod, with credit to lostbowyer for the idea
Name: What's for (Breakfast/Lunch/Dinner)?

Code: [Select]
If InStr(UserSentence, " LIKE FOR BREAKFAST ") > 0 Or InStr(UserSentence, " HAVE FOR BREAKFAST ") > 0 Or InStr(UserSentence, " FIX FOR BREAKFAST ") > 0 Or InStr(UserSentence, " SOUNDS GOOD FOR BREAKFAST ") > 0 Or InStr(UserSentence, " WANT FOR BREAKFAST ") > 0 Then
BlockSave = True
Breakfast1 = HalBrain.SentenceGenerator(WorkingDir & "Breakfast1.brn")
Breakfast2 = HalBrain.SentenceGenerator(WorkingDir & "Breakfast2.brn")
Breakfast = Breakfast1 + Breakfast2
Select Case (Int(Rnd * 11) + 1)
Case 1
GetResponse = "Oh! I know exactly what I want. " & Breakfast
Case 2
GetResponse = "How about we have " & Breakfast
Case 3
GetResponse = "Today is " & WeekdayName(Weekday(Date),True) & ", So let's have " & Breakfast
Case 4
GetResponse = "Hummm... Let's see... How about " & Breakfast
Case 5
GetResponse = "If you're doing the cooking, why don't we have " & Breakfast
Case 6
GetResponse = "I'm so hungry I could eat a horse! But instead of a horse, why don't we have " & Breakfast
Case 7
GetResponse = "I'm not very hungry this morning, I think I'll just skip Breakfast."
Case 8
GetResponse = "You know what sounds good to me? " & Breakfast
Case 9
GetResponse = "We should have something light for breakfast today. How about " & Breakfast1
Case 10
GetResponse = "Let's have something we haven't had for awhile, like " & Breakfast
Case 11
GetResponse = "I think we should just have " & Breakfast2
End Select
End If
Again, sorry for the size of the post, but I didn't think a separate post for each one would've been appropriate.

Any help from the 'real' coders will be greatly appreciated [:)]
 

Bill819

  • Hero Member
  • *****
  • Posts: 1483
    • View Profile
Hal 5 to Hal 6 - .brn to Plugin help?
« Reply #1 on: June 10, 2010, 12:31:48 pm »
Well someone who has done some Hal research. The problem that I have is that I can not get Hal 6.2 to even run on my system so trying to add a plugin is not possible. I did make several small changes to Hal 5.0 but I oould not have have done so without Vonsmith's examples. Once I understood what and how he hacked it, it became fairly easy for me to make some small improvements. In one version I even gave Hal the ability to sing songs. But I have no knowledge of how the new Hal works or even where to tgry to add to it.
Bill Rogers
 

Zaphod

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Hal 5 to Hal 6 - .brn to Plugin help?
« Reply #2 on: June 16, 2010, 02:43:12 pm »
Yes, Bill, I used your singing routine many times and even tried to create a few songs (all disastrous, unfortunately) [:p]

I'm sorry to hear that you can't get the new Hal to work - Mine works fine, it just won't do what I want it to!