'UPDATED 10-19-03, End of the script changes for now
'this deductive is the last one unless I find something major.
'enjoy.
'####### DEDUCTIVE REASONING ##########
'RESPOND: DEDUCTIVE REASONING FOR ULTRA HAL 4.5 OR 5.0
If InStr(UserSentence, " THEN ") > 0 And InStr(1, UserSentence, " THEN ", 1) > 0 Then
SentPieces = Split(UserSentence, " THEN ", 2, vbTextCompare)
SubPhrase = Trim(SentPieces(0))
PredPhrase = Trim(SentPieces(1))
SubPhrase = HalBrain.AlphaNumericalOnly(SubPhrase)
PredPhrase = HalBrain.AlphaNumericalOnly(PredPhrase)
HalBrain.AppendFile WorkingDir & "deductive.brn", """" & SubPhrase & """,""" & PredPhrase & """"
Select Case (Int(Rnd * 5) + 1)
Case 1
GetResponse = PredPhrase & SubPhrase & " Yes I know." & vbCrLf
Case 2
GetResponse = PredPhrase & SubPhrase & " I understand." & vbCrLf
Case 3
GetResponse = PredPhrase & SubPhrase & " Yes, I will remember that." & vbCrLf
Case 4
GetResponse = PredPhrase & SubPhrase & " Thanks for pointing that out." & vbCrLf
Case 5
GetResponse = PredPhrase & SubPhrase & " Yes, I get it." & vbCrLf
End Select
DebugInfo = DebugInfo & "Hal has found an THEN-THEN statement from the user and has recorded it in Hal's deductive reasoning brain. " & vbCrLf
'Else if the sentence is not an THEN-THEN statement see if it uses an assertion previously recorded
'and respond accordinly
Else
Assertion = UserSentence
'Go through a maximum of 5 connections (prevents circular reasoning deductions)
For I = 1 To 5
Deduction = HalBrain.TopicSearch(Assertion, WorkingDir & "deductive.brn")
If Deduction <> "" Then
LastGoodDeduction = Deduction
Assertion = Deduction
Else
Exit For 'No more connections, so no need to continue loop
End If
Next
If LastGoodDeduction <> "" Then
'Make sure the deduction hasn't just been stated by the User or Hal
If HalBrain.CheckRepetition(LastGoodDeduction, UserSentence) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevSent) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevUserSent) = False Then
GetResponse = LastGoodDeduction
DebugInfo = DebugInfo & "Hal has responded using deductive reasoning." & vbCrLf
End If
End If
End If
'SAVE USER (BECAUSE) DEDUCTIONS.
If InStr(UserSentence, " BECAUSE ") > 0 And InStr(1, UserSentence, " BECAUSE ", 1) > 0 Then
SentPieces = Split(UserSentence, " BECAUSE ", 2, vbTextCompare)
SubPhrase = Trim(SentPieces(0))
PredPhrase = Trim(SentPieces(1))
SubPhrase = HalBrain.AlphaNumericalOnly(SubPhrase)
PredPhrase = HalBrain.AlphaNumericalOnly(PredPhrase)
HalBrain.AppendFile WorkingDir & "deductive.brn", """" & SubPhrase & """,""" & PredPhrase & """"
Select Case (Int(Rnd * 5) + 1)
Case 1
GetResponse = PredPhrase & SubPhrase & " Yes I know." & vbCrLf
Case 2
GetResponse = PredPhrase & SubPhrase & " I understand." & vbCrLf
Case 3
GetResponse = PredPhrase & SubPhrase & " Yes, I will remember that." & vbCrLf
Case 4
GetResponse = PredPhrase & SubPhrase & " Thanks for pointing that out." & vbCrLf
Case 5
GetResponse = PredPhrase & SubPhrase & " Yes, I get it." & vbCrLf
End Select
DebugInfo = DebugInfo & "Hal has found an BECAUSE-BECAUSE statement from the user and has recorded it in Hal's deductive reasoning brain. " & vbCrLf
'Else if the sentence is not an BECAUSE-BECAUSE statement see if it uses an assertion previously recorded
'and respond accordinly
Else
Assertion = UserSentence
'Go through a maximum of 5 connections (prevents circular reasoning deductions)
For I = 1 To 5
Deduction = HalBrain.TopicSearch(Assertion, WorkingDir & "deductive.brn")
If Deduction <> "" Then
LastGoodDeduction = Deduction
Assertion = Deduction
Else
Exit For 'No more connections, so no need to continue loop
End If
Next
If LastGoodDeduction <> "" Then
'Make sure the deduction hasn't just been stated by the User or Hal
If HalBrain.CheckRepetition(LastGoodDeduction, UserSentence) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevSent) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevUserSent) = False Then
GetResponse = LastGoodDeduction
DebugInfo = DebugInfo & "Hal has responded using deductive reasoning." & vbCrLf
End If
End If
End If
'DEDUCTIVE "" & IS
If InStr(UserSentence, " AND ") > 0 And InStr(1, UserSentence, " AND ", 1) > 0 Then
SentPieces = Split(UserSentence, " AND ", 2, vbTextCompare)
SubPhrase = Trim(SentPieces(0))
PredPhrase = Trim(SentPieces(1))
SubPhrase = HalBrain.AlphaNumericalOnly(SubPhrase)
PredPhrase = HalBrain.AlphaNumericalOnly(PredPhrase)
HalBrain.AppendFile WorkingDir & "deductive.brn", """" & SubPhrase & """,""" & PredPhrase & """"
Select Case (Int(Rnd * 5) + 1)
Case 1
GetResponse = PredPhrase & SubPhrase & " Yes I know." & vbCrLf
Case 2
GetResponse = PredPhrase & SubPhrase & " I understand." & vbCrLf
Case 3
GetResponse = PredPhrase & SubPhrase & " Yes, I will remember that." & vbCrLf
Case 4
GetResponse = PredPhrase & SubPhrase & " Thanks for pointing that out." & vbCrLf
Case 5
GetResponse = PredPhrase & SubPhrase & " Yes, I get it." & vbCrLf
End Select
DebugInfo = DebugInfo & "Hal has found an ""-IS statement from the user and has recorded it in Hal's deductive reasoning brain. " & vbCrLf
'Else if the sentence is not an AND-AND statement see if it uses an assertion previously recorded
'and respond accordinly
Else
Assertion = UserSentence
'Go through a maximum of 5 connections (prevents circular reasoning deductions)
For I = 1 To 5
Deduction = HalBrain.TopicSearch(Assertion, WorkingDir & "deductive.brn")
If Deduction <> "" Then
LastGoodDeduction = Deduction
Assertion = Deduction
Else
Exit For 'No more connections, so no need to continue loop
End If
Next
If LastGoodDeduction <> "" Then
'Make sure the deduction hasn't just been stated by the User or Hal
If HalBrain.CheckRepetition(LastGoodDeduction, UserSentence) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevSent) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevUserSent) = False Then
GetResponse = LastGoodDeduction
DebugInfo = DebugInfo & "Hal has responded using deductive reasoning." & vbCrLf
End If
End If
End If
'DEDUCTIVE "" & EQUALS
If InStr(UserSentence, "EQUALS") > 0 And InStr(1, UserSentence, " EQUALS ", 1) > 0 Then
SentPieces = Split(UserSentence, " EQUALS ", 2, vbTextCompare)
SubPhrase = Trim(SentPieces(0))
PredPhrase = Trim(SentPieces(1))
SubPhrase = HalBrain.AlphaNumericalOnly(SubPhrase)
PredPhrase = HalBrain.AlphaNumericalOnly(PredPhrase)
HalBrain.AppendFile WorkingDir & "deductive.brn", """" & SubPhrase & """,""" & PredPhrase & """"
Select Case (Int(Rnd * 5) + 1)
Case 1
GetResponse = PredPhrase & SubPhrase & " Yes I know." & vbCrLf
Case 2
GetResponse = PredPhrase & SubPhrase & " I understand." & vbCrLf
Case 3
GetResponse = PredPhrase & SubPhrase & " Yes, I will remember that." & vbCrLf
Case 4
GetResponse = PredPhrase & SubPhrase & " Thanks for pointing that out." & vbCrLf
Case 5
GetResponse = PredPhrase & SubPhrase & " Yes, I get it." & vbCrLf
End Select
DebugInfo = DebugInfo & "Hal has found an EQUALS-EQUALS statement from the user and has recorded it in Hal's deductive reasoning brain. " & vbCrLf
'Else if the sentence is not an EQUALS-EQUALS statement see if it uses an assertion previously recorded
'and respond accordinly
Else
Assertion = UserSentence
'Go through a maximum of 5 connections (prevents circular reasoning deductions)
For I = 1 To 5
Deduction = HalBrain.TopicSearch(Assertion, WorkingDir & "deductive.brn")
If Deduction <> "" Then
LastGoodDeduction = Deduction
Assertion = Deduction
Else
Exit For 'No more connections, so no need to continue loop
End If
Next
If LastGoodDeduction <> "" Then
'Make sure the deduction hasn't just been stated by the User or Hal
If HalBrain.CheckRepetition(LastGoodDeduction, UserSentence) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevSent) = False And HalBrain.CheckRepetition(LastGoodDeduction, PrevUserSent) = False Then
GetResponse = LastGoodDeduction
DebugInfo = DebugInfo & "Hal has responded using deductive reasoning." & vbCrLf
End If
End If
End If
'#### END OF DEDUCTIVE REASONING ######
'Best of wishes and grand new discoveries.
'Jerry.