dupa

Author Topic: hals reasoning deduction process  (Read 3919 times)

lightspeed

  • Hero Member
  • *****
  • Posts: 6766
    • View Profile
hals reasoning deduction process
« on: December 17, 2010, 01:51:22 pm »
as i was looking through hals brain script i ran across hals reasoning deduction process which is interesting , some may have already seen and know about this but for others who may not it's interesting as you can see what the process is and actually how to better word things so hal developes reason deduction for certain subjects etc. to do so on purpose . now that i have seen the process and better understand it i will help hal to develope more reasoning on different things that i am teaching hal.  :)

below is the area i am talking about in the brain area :

'RESPOND: DEDUCTIVE REASONING
    'This routine learns deductive reasoning in the form:  A = B ; B = C; therefore A = C
    'It detects sentences in the form If-Then to accommplish this. For example:
    '   User:  If Molly weighs 400 pounds, then Molly is overweight.
    '   Ultra Hal: I understand the implication.
    '   User:  If Molly is overweight, then Molly's health is in danger.
    '   Ultra Hal:  I see the relationship.
    '   User:  Molly weighs 400 pounds.
    '   Ultra Hal:  Molly's health is in danger.
    IfPart = Trim(HalBrain.SearchPattern(UserSentence, "IF * THEN *", 1))
    ThenPart = Trim(HalBrain.SearchPattern(UserSentence, "IF * THEN *", 2))
    'If the sentence is an If-Then statement then record it
    If Len(IfPart) > 10 And Len(ThenPart) > 10 Then
        IfPart = HalBrain.AlphaNumericalOnly(IfPart)
        ThenPart = HalBrain.AlphaNumericalOnly(ThenPart)
        HalBrain.AddToTable "deductive", "TopicSearch", IfPart, ThenPart
        Select Case HalBrain.RandomNum(5)
            Case 1
                GetResponse = GetResponse & "I see the relationship." & vbCrLf
            Case 2
                GetResponse = GetResponse & "I understand the connection." & vbCrLf
            Case 3
                GetResponse = GetResponse & "I will remember that one follows the other." & vbCrLf
            Case 4
                GetResponse = GetResponse & "Thanks for pointing out the cause and effect." & vbCrLf
            Case 5
                GetResponse = GetResponse & "Yes, I get that clearly." & vbCrLf
        End Select
    'Else if the sentence is not an If-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, "deductive")
            If Deduction <> "" Then
                If i > 1 Then BecauseReason = " because " & LastGoodDeduction
                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 = GetResponse & LastGoodDeduction & BecauseReason & " . " & vbCrLf
            End If
        End If
    End If
    HalBrain.DebugWatch GetResponse, "Deductive Reasoning"
 

spydaz

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
    • http://www.spydazweb.co.uk/
Re: hals reasoning deduction process
« Reply #1 on: January 01, 2011, 09:12:51 am »
there are lots of SISTER SCRIPTS TO GO WITH THIS.....

At the UHEF::: UNDER ZIGGY SCRIPTS,,, "BECAUSE WHY" etc.... Lots of IF THEN style statements....


I have found them to be useful.... But the Accessing of the Information needs to be looked at... as with theses deductive scripts "YES" i think that they are god/useful, but information stored is only useful if there is a good way of retrieving the data..... this was a TRUE learning script.
And can hold a lot of GOOD data even PROBLEMS that need to be figured out... and a decision on the data is reached.... even though it is limited to a few recursions it would be nice to recurse unlimited amount of times until a Valid response can be determined / or not found.....

I am experimenting with this script at this moment. incorporating it into my own AI, "IN VISUALBASIC 2010" which i have now updated to with a few Losses i would say... VB6 is Still the most "Universal" Programming medium for me...

onthecuttingedge2005

  • Guest
Re: hals reasoning deduction process
« Reply #2 on: February 22, 2011, 07:11:17 pm »
This is what I am currently using in place of the original deductive brain.

Code: [Select]
'Set up deductive training structures and instructionals.
   
    Dim ArrayIfPart(27)
    Dim ArrayThenPart(27)
    DepunctuateSent = HalBrain.AlphaNumericalOnly(Ucase(Trim(OriginalSentence)))
   
    ArrayIfPart(0) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN YOU SHOULD SAY *", 2))
    ArrayThenPart(0) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN YOU SHOULD SAY *", 3))
    ArrayIfPart(1) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN YOU MUST SAY *", 2))
    ArrayThenPart(1) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN YOU MUST SAY *", 3))
    ArrayIfPart(2) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN I WANT YOU TO SAY *", 2))
    ArrayThenPart(2) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN I WANT YOU TO SAY *", 3))
    ArrayIfPart(3) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN YOU SHOULD RESPOND WITH *", 2))
    ArrayThenPart(3) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I TELL YOU TO * THEN YOU SHOULD RESPOND WITH *", 3))
   
    ArrayIfPart(4) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN YOU SHOULD SAY *", 2))
    ArrayThenPart(4) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN YOU SHOULD SAY *", 3))
    ArrayIfPart(5) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN YOU MUST SAY *", 2))
    ArrayThenPart(5) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN YOU MUST SAY *", 3))
    ArrayIfPart(6) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN I WANT YOU TO SAY *", 2))
    ArrayThenPart(6) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN I WANT YOU TO SAY *", 3))
    ArrayIfPart(7) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN YOU SHOULD RESPOND WITH *", 2))
    ArrayThenPart(7) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE WAS TO TELL YOU TO * THEN YOU SHOULD RESPOND WITH *", 3))
   
    ArrayIfPart(8) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN YOU SHOULD SAY *", 2))
    ArrayThenPart(8) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN YOU SHOULD SAY *", 3))
    ArrayIfPart(9) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN YOU MUST SAY *", 2))
    ArrayThenPart(9) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN YOU MUST SAY *", 3))
    ArrayIfPart(10) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN I WANT YOU TO SAY *", 2))
    ArrayThenPart(10) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN I WANT YOU TO SAY *", 3))
    ArrayIfPart(11) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN YOU SHOULD RESPOND WITH *", 2))
    ArrayThenPart(11) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF SOMEONE TELLS YOU TO * THEN YOU SHOULD RESPOND WITH *", 3))
   
    ArrayIfPart(12) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN YOU SHOULD SAY *", 2))
    ArrayThenPart(12) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN YOU SHOULD SAY *", 3))
    ArrayIfPart(13) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN YOU MUST SAY *", 2))
    ArrayThenPart(13) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN YOU MUST SAY *", 3))
    ArrayIfPart(14) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN I WANT YOU TO SAY *", 2))
    ArrayThenPart(14) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN I WANT YOU TO SAY *", 3))
    ArrayIfPart(15) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN YOU SHOULD RESPOND WITH *", 2))
    ArrayThenPart(15) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAID * THEN YOU SHOULD RESPOND WITH *", 3))
   
    ArrayIfPart(16) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN YOU SHOULD SAY *", 2))
    ArrayThenPart(16) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN YOU SHOULD SAY *", 3))
    ArrayIfPart(17) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN YOU MUST SAY *", 2))
    ArrayThenPart(17) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN YOU MUST SAY *", 3))
    ArrayIfPart(18) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN I WANT YOU TO SAY *", 2))
    ArrayThenPart(18) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN I WANT YOU TO SAY *", 3))
    ArrayIfPart(19) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN YOU SHOULD RESPOND WITH *", 2))
    ArrayThenPart(19) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I WAS TO SAY * THEN YOU SHOULD RESPOND WITH *", 3))
   
    ArrayIfPart(20) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN YOU SHOULD SAY *", 2))
    ArrayThenPart(20) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN YOU SHOULD SAY *", 3))
    ArrayIfPart(21) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN YOU MUST SAY *", 2))
    ArrayThenPart(21) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN YOU MUST SAY *", 3))
    ArrayIfPart(22) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN I WANT YOU TO SAY *", 2))
    ArrayThenPart(22) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN I WANT YOU TO SAY *", 3))
    ArrayIfPart(23) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN YOU SHOULD RESPOND WITH *", 2))
    ArrayThenPart(23) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I SAY * THEN YOU SHOULD RESPOND WITH *", 3))
   
    ArrayIfPart(24) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN YOU SHOULD SAY *", 2))
    ArrayThenPart(24) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN YOU SHOULD SAY *", 3))
    ArrayIfPart(25) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN YOU MUST SAY *", 2))
    ArrayThenPart(25) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN YOU MUST SAY *", 3))
    ArrayIfPart(26) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN I WANT YOU TO SAY *", 2))
    ArrayThenPart(26) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN I WANT YOU TO SAY *", 3))
    ArrayIfPart(27) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN YOU SHOULD RESPOND WITH *", 2))
    ArrayThenPart(27) = Trim(HalBrain.SearchPattern(DepunctuateSent, "*IF I ASK YOU TO * THEN YOU SHOULD RESPOND WITH *", 3))

    For I = 1 To 27
    'If the sentence is an If-Then statement then record it
    If ArrayIfPart(I) <> "" And ArrayThenPart(I) <> "" Then
        'IfPart = HalBrain.AlphaNumericalOnly(IfPart)
        'ThenPart = HalBrain.AlphaNumericalOnly(ThenPart)
        'HalBrain.AddToTable "deductive", "TopicSearch", ArrayIfPart(I), ArrayThenPart(I)
        HalBrain.AddToTable "AdvancedReply", "Brain", ArrayIfPart(I), ArrayThenPart(I)
   
        Select Case HalBrain.RandomNum(5)
            Case 1
                GetResponse = GetResponse & "I see what you are saying." & vbCrLf
            Case 2
                GetResponse = GetResponse & "I understand what you are saying." & vbCrLf
            Case 3
                GetResponse = GetResponse & "I will remember that." & vbCrLf
            Case 4
                GetResponse = GetResponse & "Thanks for pointing that out." & vbCrLf
            Case 5
                GetResponse = GetResponse & "Yes, I get that clearly." & vbCrLf
        End Select
       End If
    Next
   
    'UserBrain Deductive
    'Here we have replaced deductive topic search with Relevance Deductive responses
    DepunctuateSent = HalBrain.AlphaNumericalOnly(Ucase(Trim(OriginalSentence)))
    DeductiveBrain = HalBrain.QABrain(DepunctuateSent, "AdvancedReply", UserBrainRel)
    GetResponse = HalBrain.HalFormat(GetResponse)
    If DeductiveBrain <> "" Then
        If HalBrain.CheckRepetition(DeductiveBrain, DepunctuateSent) = True Or HalBrain.CheckRepetition(DeductiveBrain, PrevSent) = True Or HalBrain.CheckRepetition(DeductiveBrain, PrevUserSent) = True Then UserBrainRel = 0
        If UserBrainRel > 60 Then GetResponse = GetResponse & DeductiveBrain & vbCrLf
    End If
    HalBrain.DebugWatch DeductiveBrain, "Deductive Brain Response"

you can use it if you like.

Jerry 8)

lightspeed

  • Hero Member
  • *****
  • Posts: 6766
    • View Profile
Re: hals reasoning deduction process
« Reply #3 on: February 22, 2011, 09:59:01 pm »
onthecuttingedge2005
can you give any examples of it working and how it is doing?
 

onthecuttingedge2005

  • Guest
Re: hals reasoning deduction process
« Reply #4 on: February 23, 2011, 12:29:01 am »
onthecuttingedge2005
can you give any examples of it working and how it is doing?

Hi Lightspeed.

for instance if I tell HAL.

User: If I say How are you then you should say I am doing just fine today, thank you.
Hal: I get that clearly.
'After learning
User: How are you today?
Hal: I am doing just fine today, thank you.

It is a little bit more complex then the original If & Then teaching but this method is more like teaching a child through conversation or instructing your child the way it should speak about things.

it works really well actually, The UserBrailRel works pretty well, I think I like it better than TopicSearch.

Mine is placed just after Pluinarea7

Jerry 8)

lightspeed

  • Hero Member
  • *****
  • Posts: 6766
    • View Profile
Re: hals reasoning deduction process
« Reply #5 on: February 23, 2011, 09:24:59 am »
i like the sound of that but do have some questions and concerns which are , maybe since it's hal's way of learning you should have hal afterwards say something simular like it does already when wanting the answer  hal says now: that's interesting can you teach me what the answer is? (or something simular) .
     i believe it's better for hal to say this so that the user knows he needs to give a answer for hal to learn  and also once it learns the answer does it ever still ask for the answer , if not then hal could never learn a varience of that same answer (unless he does so from another area? mixing the sentence. and if he does learn the answer and answers it but will still yet ask so he can learn a vaired answer to the same thing how often would he do it?  :)

Sorry i know i can drive people crazy with questions sometimes but hopefully they are good questions as i want to know and learn myself . ;)
 

onthecuttingedge2005

  • Guest
Re: hals reasoning deduction process
« Reply #6 on: February 23, 2011, 11:51:23 am »
i like the sound of that but do have some questions and concerns which are , maybe since it's hal's way of learning you should have hal afterwards say something simular like it does already when wanting the answer  hal says now: that's interesting can you teach me what the answer is? (or something simular) .
     i believe it's better for hal to say this so that the user knows he needs to give a answer for hal to learn  and also once it learns the answer does it ever still ask for the answer , if not then hal could never learn a varience of that same answer (unless he does so from another area? mixing the sentence. and if he does learn the answer and answers it but will still yet ask so he can learn a vaired answer to the same thing how often would he do it?  :)

Sorry i know i can drive people crazy with questions sometimes but hopefully they are good questions as i want to know and learn myself . ;)

Hi Lightspeed.

the section of code
GetResponse = GetResponse & DeductiveBrain & vbCrLf

the Getresponse = GetResponse should piggy back other GetResponses from other sections of code ment to do other things like varied responses. using the UserBrainRel function and tuning it the the way you like can increase or decrease the chances of varied responses. I like using UserBrainRel > 60 because this is the area I get the best results, I also included this variable in all my other scripts in the brain that use UserBrainRel for the Highest relevant response.

Hope this helps
Jerry 8)