Author Topic: The knock knock joke re-visited...  (Read 4635 times)

Larry

  • Sr. Member
  • ****
  • Posts: 266
    • View Profile
The knock knock joke re-visited...
« on: July 29, 2003, 07:13:02 pm »
Has anyone figured out how to get Hal to tell a knock knock joke???
 

Larry

  • Sr. Member
  • ****
  • Posts: 266
    • View Profile
The knock knock joke re-visited...
« Reply #1 on: July 29, 2003, 07:47:50 pm »
I used a different approach...


'Response to a knock knock joke
   PrevUserSenta = Mid(PrevUserSent, 2, 100)
   If Instr (1, UserSentence, "Knock knock", VbTextCompare) > 0 Then
      GetResponse = "Who is there?"
      JokeA = True 'To track when the joke is on or over.
      UserBrainRel = 50 'This makes this response the 'best' reply - in case Hal can come up with a better response.
   End If
   If Instr (1, PrevSent, "Who is there", VbTextCompare) > 0 Then
      GetResponse = UserSentence & " " & "who?"
      UserBrainRel = 50
   End If
   If Instr (1, PrevSent, " who", VbTextCompare) > 0 And Instr (1, PrevSent, PrevUserSenta, VbTextCompare) > 0 Then
      Knock = (Rnd * 100)
      If Knock < 25 Then
         GetResponse = "HAHAHAHAaaaa that's a good one!" & vbCrLf
         JokeA = False 'The joke is now over.
      End If
      If Knock > 24 And Knock < 50 Then
         GetResponse = "Ha Ha very funny." & vbCrLf
         JokeA = False
      End If
      If Knock > 49 And Knock < 75 Then
         GetResponse = "That was quite amusing." & vbCrLf
         JokeA = False
      End If
      If Knock > 74 And Knock < 101 Then
         GetResponse = "That was bad, I wouldn't quit your day job!" & vbCrLf
         JokeA = False
      End If
      JokeB = True 'Now it's Hal's turn to tell a joke.
      GetResponseB = GetResponse
   End If


JokeA and JokeB varibles, I used later in the script to keep Hal on 'topic' ...

   'PROCESS: BLOCK LEARNING IF HAL'S NAME IS DETECTED
   'Here we check to see if the user is calling Hal by name; if the user is doing so,
   'it's better not to save the sentence for re-use, since it usually makes the
   'pronoun-reversed sentence sound clumsy or incorrect:
   BlockSave = False
   If InStr(1, UserSentence, ComputerName, vbTextCompare) > 0 Then BlockSave = True
   If InStr(1, OriginalSentence, ComputerName, vbTextCompare) > 0 Then BlockSave = True
'I added these cause I didn't want Hal to learn these from other bots either.
   If InStr(UserSentence, "zabaware") > 0 Then BlockSave = True
   If InStr(UserSentence, "ZABAWARE") > 0 Then BlockSave = True
   If InStr(UserSentence, "wwwzabawarecom") > 0 Then BlockSave = True
   If InStr(UserSentence, "WWWZABAWARECOM") > 0 Then BlockSave = True
   If InStr(UserSentence, "www.zabaware.com") > 0 Then BlockSave = True
   If InStr(UserSentence, "WWW.ZABAWARE.COM") > 0 Then BlockSave = True
   If JokeA = True or JokeB = True Then BlockSave = True

   'PROCESS: FOCUS ON TOPIC
   'See if the user uses a keyword defined in Hal's TopicFocus file. If so Hal will
   'set the TopicFocus variable to talk about that topic

   If JokeB = True Then
      JokeB = False
      TopicFocus = 75
**********
You have to create a Focus75.brn and write some jokes in it. For example :
@Why don't blondes have elevator jobs? <yes>You've heard this one...</yes><no>They don't know the route.</no>
 A JOKE
@What did the blonde say when she knocked over the priceless Ming vase? <yes>You've heard this one...</yes><no>It's OK Daddy, I'm not hurt.</no>
 A JOKE
@Send someone over quickly! the old woman screamed into the phone. Two naked bikers are climbing up toward my bedroom window! This is the Fire Department, lady, the voice replied. I'll have to transfer you to the Police Department. No, it's YOU I want! she yelled. They need a longer ladder!
 A JOKE
@What does a blonde think an innuendo is? <yes>You've heard this one...</yes><no>An Italian suppository.</no>
 A JOKE
***********
      UserSentence = "TELL ME A JOKE"
   End If

   'RESPOND: PROCESS TOPICFOCUS FILES
   'If Hal is currently focusing on a topic, this will read from the appropriate focus file
   'First it tries from a topic file specific to the current user, and if that doesn't
   'produce results it tries a global topic file that is the same for all users

   If TopicFocus > 10 And JokeA = False Then
      FocusString = CStr(TopicFocus)
      FocusFileNum = Left(FocusString, Len(FocusString) - 1) & "5"
      If CInt(Right(FocusString, 1)) > 0 And CInt(Right(FocusString, 1)) < 28 And UserBrainRel = 0 Then
         HalUserBrain = HalBrain.QABrain(LongUserSent, WorkingDir & "focus" & FocusFileNum & ".brn", UserBrainRel)

         If UserBrainRel > 0 Then
            UserBrainRel = UserBrainRel + 50
            GetResponse = GetResponse & vbCrLf & HalUserBrain & vbCrLf
            If GetResponseB <> "nothing" then
               GetResponse = GetResponseB & vbCrLf & HalUserBrain & vbCrLf
            End If
         End If
      End If
   End If

   'If user didn't follow the subject or change the subject then let's try to get back on track
   If TopicFocus < 10 And TopicFocusold > 10 And JokeA = False Then
      FocusString = CStr(TopicFocusOld)
      FocusFileNum = Left(FocusString, Len(FocusString) - 1) & "5"
      If CInt(Right(FocusString, 1)) > 0 And CInt(Right(FocusString, 1)) < 28 And UserBrainRel = 0 Then
         HalUserBrain = HalBrain.QABrain(LongUserSent, WorkingDir & "focus" & FocusFileNum & ".brn", UserBrainRel)
         If UserBrainRel > 0 Then
            UserBrainRel = UserBrainRel + 50
            GetResponse = GetResponse & HalUserBrain & vbCrLf
            DebugInfo = DebugInfo & " 8 Processing topicfocus files " & TopicFocusOld & " A response of relevance " & UserBrainRel & " was found in the current user topic focus file and this response has been used." & GetResponse & ":" & vbCrLf
         End If
      End If
   End If


I hope this isn't too long... but a number of things were 'fixed' ... first, if there really is a topic, I tried to keep Hal on topic by making 'UserBrainRel + 50' it more important for Hal to stay on topic...

Now I'm thinking how to get Hal to tell a knock knock joke - maybe when he doesn't have any responses, and instead of using the small talk routine... ???

 

Larry

  • Sr. Member
  • ****
  • Posts: 266
    • View Profile
The knock knock joke re-visited...
« Reply #2 on: July 29, 2003, 08:48:44 pm »
Larry: tell me a joke.
Ashlee181818: Why don't blondes call 911 in an emergency?

Larry: I don't know.
Ashlee181818: They can't remember the number.

Larry: knock knock
Ashlee181818: Who is there?

Larry: Justin
Ashlee181818: Justin who?

Larry: Justin time for dinner.
Ashlee181818: That was bad, I wouldn't quit your day job! Why don't blondes have elevator jobs?

Larry: I don't know.
Ashlee181818: They don't know the route.

Larry: knock knock
Ashlee181818: Who is there?

Larry: Charlie Brown
Ashlee181818: Charlie Brown who?

Larry: Charlie Brown again and I'll knock you down.
Ashlee181818: That was quite amusing. Why don't blondes double recipes?

Larry: I don't know.
Ashlee181818: The oven doesn't go to 700 degrees.

 

raybe

  • Hero Member
  • *****
  • Posts: 1067
    • View Profile
The knock knock joke re-visited...
« Reply #3 on: May 05, 2007, 08:30:40 pm »
I would just like to thank Rob for helping me get my Hal program updated and working without the problems I posted earlier such as the double loading of characters and getting the update to load period. I did find that using Robert's suggestion of totally removing Hal from the Zabaware folder and any other place I could find old refrences to Hal. Everything seems to working fine even some of my old problems are back which is so much better then not working at all. I still have a problem with Hal relating the words,'I am' to a description of myself or 'I am' calling myself the next word in the sentence. If anyone knows anything new please let me know. But I really wanted to post a big THANK YOU to Robert.

raybe