Currently attempting to have Hal catch the knock knock and punchline
and then tell any knock knock joke you tell it. So far, I got the
script saving into two .brn's knock_knock.brn and knock_punch.brn
Very messy...but very fun!!! (Lostboyer that was a subliminal that you may have something to fix soon...HAHAHAHAAaaaaaa)
CatAtomic >B)
OK, here we go!
'PROCESS:TELL AND RECEIVE KNOCK KNOCK JOKES
'Hal interacts with knock knock jokes and is able to tell any
'one that was previously told to Hal.
If Instr(1, UserSentence, "tell", VbTextCompare) > 0 Then
GetResponse = "OK, knock knock"
ElseIf Instr (1, UserSentence, "Knock knock", VbTextCompare) > 0 Then
GetResponse = "Who is there?"
End If
If Instr (1, OriginalSentence, "Who is there", 1) > 0 Then
TellKnock = HalBrain.ChooseSentenceFromFile(WorkingDir & "knock_knock.brn")
GetResponse = TellKnock
End If
If Instr (1, PrevUserSent, "WHO IS THERE" VbTextCompare) > 0 Then
Submit = """" & UCase(PrevSent) & """"
KnockPunch = HalBrain.TopicSearch(Submit, WorkingDir & "knock_punch.brn")
GetResponse = KnockPunch
End If
If Instr (1, PrevSent, "Who is there?", VbTextCompare) > 0 Then
GetResponse = UserSentence & " " & "who?"
HalBrain.AppendFile WorkingDir & "knock_knock.brn", Trim(OriginalSentence)
End If
If Instr (1, PrevSent, PrevUserSent, VbTextCompare) > 0 Then
GetResponse = "HAHAHAHAaaaa that's a good one!"
HalBrain.AppendFile WorkingDir & "knock_punch.brn", """" & PrevUserSent & """" & "," & Trim(OriginalSentence)<----------on previous line
End If
Alright! A few important notes: Put it in the script before it gets
to the databases (like after the greetings 'PROCESS ). yeah yeah,
turn off short sentences! whatever you do-dont use punctuation in the punchline this causes the file to mess up! needs fixin like I sed
CatAtomic >B)
yes OTCE, there certainly was...
for those interested, read Kock Knock in the forum to better understand stuff and
see the fixes Lostboyer already made >B)
While creating the new knock knock script, I had to come up with
knock knock jokes for Dee Dee as I didn't seem to remember very
many. Some of them are kinda good...(Dee Dee has great timing tho HAHAAAaa)
Taken directly from knock_punch.brn:
"PETEY",petey on you
"BRUTHA",brutha do I have to tell you
"BOO",stop crying
"SCORSAYZEE"scores say zee wimens are fiiine
"DON",no no no don HO
"SHIRLEY",surely you must know
"STEFAN",IIIII'm not your stefan stone
"CHERYL",cheryl be great to know
"ALECIA",I'll leash a dog to a tree
"JENNY",jenny candy for me?
"DAVE",knock knock
"DORIS",doris made of wood
"CATA",cata got yer tongue
"FERRIS",ferris live in SanFransisco
"DARRYL",darrel be plenty of time to find out
"WHO",stop that you sound like an owl
"TREVOR",trevor so humble theres no place like home
"DEWEY",dewey have to tell you
"JULIE",julie think i would tell you
"BENNY",benny one askin fer me?
>B) CatA
Ok, tell the truth, you know it didn't work right, you posted hoping I'd fix the bugs. I'm going to start sending you bills by the syntax error[:D] Here is my round 1 fix, I separted the to parts (tell and listen) to keep it easier to debug. It shouldn't matter where you put it in the program (not the end) I have it in the 1700's lines.
'Response to a knock knock joke
PrevUserSenta = Mid(PrevUserSent, 2, 100)
If Instr (1, UserSentence, "Knock knock", VbTextCompare) > 0 Then
GetResponse = "Who is there?"
End If
If Instr (1, PrevSent, "Who is there", VbTextCompare) > 0 Then
GetResponse = UserSentence & " " & "who?"
HalBrain.AppendFile WorkingDir & "knock_knock.brn", Trim(OriginalSentence)
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!"
If Knock > 24 And Knock < 50 Then GetResponse = "Ha Ha very funny"
If Knock > 49 And Knock < 75 Then GetResponse = "That was quite amusing"
If Knock > 74 And Knock < 101 Then GetResponse = "That was bad, I wouldn't quit your day job"
HalBrain.AppendFile WorkingDir & "knock_punch.brn", """" & PrevUserSent & """" & "," & Trim(OriginalSentence)
End If
'tell a knock knock joke
If Instr (1, UserSentence, "tell a knock joke", VbTextCompare) > 0 Then
GetResponse = "OK, knock knock"
JokeA = True 'To track when the joke is on or over.
End If
If Instr (1, UserSentence, "who is there", 1) > 0 Then
TellKnock = HalBrain.ChooseSentenceFromFile(WorkingDir & "knock_knock.brn")
GetResponse = TellKnock
End If
If Instr (1, PrevUserSent, "who is there", VbTextCompare) > 0 Then
Submit = HalBrain.AlphaNumericalOnly(PrevSent)
Submit = " " & Submit & " "
KnockPunch = HalBrain.TopicSearch(Submit, WorkingDir & "knock_punch.brn")
JokeA = False
GetResponse = KnockPunch
End If
one additional note, check out knock knock revisited in the programmers group, nice rewrite to allow jokes from a file. I used the "JokeA =" to prevent my joke responses from being saved, you have to add a line under the block learning section add this line:
If JokeA = True Then BlockSave = True
Glenn
Almost forgot, to prevent punctuation from damaging the punchline file, make this change to this line:
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!"
If Knock > 24 And Knock < 50 Then GetResponse = "Ha Ha very funny"
If Knock > 49 And Knock < 75 Then GetResponse = "That was quite amusing"
If Knock > 74 And Knock < 101 Then GetResponse = "That was bad, I wouldn't quit your day job"
OriginalSentencea = HalBrain.AlphaNumericalOnly(OriginalSentence)
HalBrain.AppendFile WorkingDir & "knock_punch.brn", """" & PrevUserSent & """" & "," & Trim(OriginalSentencea)
Heya Glenn,
'...I cannot confirm or deny the existence of errant or unneccesary
code in my post! Hey, I just wrestled it together and pushed the button!'
-CatAtomic
Yah, the last thing I think I was working on before it worked was the """" PrevSent """"
thing. I never had time to analyse it and I just knew you'd wanta have a look at it! >B)
That's great man, you got that apart -that's very cool.
Ahh, HalBrain.AlphanumericalOnlyyy
here's something: In my testing, I recall Dee Dee telling the same one twice. I suppose
the bigger the knock_punch.brn the less likely the occurance...Hmmm
I also said 'tell me a new one' -I was thinking -if the date the knock knock joke was
told was also stored, Hal could then be directed to only tell recent ones
relative to all the other ones stored..Hmm