Author Topic: Experimental v4.5 deductive reasoning scripts  (Read 3509 times)

onthecuttingedge2005

  • Guest
Experimental v4.5 deductive reasoning scripts
« on: October 17, 2003, 07:48:08 pm »
'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.
« Last Edit: October 19, 2003, 07:31:21 pm by onthecuttingedge2005 »

Ponnfar

  • Full Member
  • ***
  • Posts: 149
    • View Profile
    • http://zabaware.com
Experimental v4.5 deductive reasoning scripts
« Reply #1 on: October 19, 2003, 11:06:20 pm »
This sounds like a great idea. I imagine it is a great script. In referenece to my previous question, where do I place this script? I assume I can simply cut an paste. Further, If I wanted to have HAL execute programs without giving the full pathname, perhaps teaching HAL an abbeviation for the full pathname, can HAL deduce my meaning? If not, how do I edit the brain scripts manually to execute programs using my shortcuts or verbage?
Thanks
One Person can summon the future...

onthecuttingedge2005

  • Guest
Experimental v4.5 deductive reasoning scripts
« Reply #2 on: October 19, 2003, 11:30:24 pm »
Hi Ponnfar.

I "start" pasting scripts below the script for
hal repeating himself line.
I'll make a green area by doing this:

'###################
'Place script here.
'###################

where the above area is highlighted green by an apostrophe
being place before your script, The green highlighted areas
have no function are only for discribing the script.
Make sure you back up your original default Hal4.uhp brain
before modifications. as for the rest of your question I'll have to work on it, we'll see if we can get something that works for you.
Best of wishes.
Jerry.

Ponnfar

  • Full Member
  • ***
  • Posts: 149
    • View Profile
    • http://zabaware.com
Experimental v4.5 deductive reasoning scripts
« Reply #3 on: October 20, 2003, 01:07:56 am »
Thanks for your quick response [:)]
I have copied your script into a brain that I simply saved with a new name. How can I test it? How do I create a sample "if-then" senario. I hesitate to ask this question but I prefer your debugging to my fumbling around any day. Thanks Jerry!
One Person can summon the future...

onthecuttingedge2005

  • Guest
Experimental v4.5 deductive reasoning scripts
« Reply #4 on: October 20, 2003, 01:52:08 am »
Hi Ponnfar.

You can test it by saying such things as:
IF Mary had a little lamb who's fleece was white as snow THEN Mary's lamb is white.
Or some other If and Then learning statements.
Like: IF Monkeys are lessor man THEN Man must be the greater monkey.
You can check to see if the script is working by looking in the
deductive.brn to see If your statement is there. If it is then it's probably working.
Best of wishes and new discoveries.
Jerry.