Author Topic: Q&A  (Read 23492 times)

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Q&A
« on: October 17, 2012, 10:15:12 am »
I would like to used the Brain editor to program Hal to troubleshoot problems. Example: User: "My computer will not power on." Hal: "Is the computer plugged in?" User:"Yes." Hal:"Are there any lights or LEDs on that suggest power to the motherboard?" User: "No." Hal: "Do you have a power supply tester?" User: "No." Hal: "There is a good possibility that your power supply maybe at fault. I suggest you either test your current power supply, or replace it." Now, if the user answered no to the question of, "Is the computer plugged in?" Hal would give the answer, "Please plug the computer into the proper outlet and proceed with normal operations."

Now I realize the countless scenarios that have to be enter into the editor, but I'm looking for a known working procedure that would give me the responses to yes or no question, and follow a logical ladder diagram.

I am a technician/engineer of sorts and I sometimes find myself over thinking problems, and issues. It would be nice to use Hal as a partner, in the realm of what I do, and keep someone around that can keep me on track, with simplicity, and logical thought.

onthecuttingedge2005

  • Guest
Re: Q&A
« Reply #1 on: October 17, 2012, 11:54:07 am »
Hi deitz.


You could always try something like this:

Code: [Select]

If InStr(1, OriginalSentence, "My computer will not power on", 1) Then Diagnostics = True
    If InStr(1, OriginalSentence, "My computer won't power on", 1) Then Diagnostics = True
    If Diagnostics = True Then         
    Select Case HalBrain.RandomNum(4)
            Case 1
                GetResponse = "Is the computer plugged in?" & vbCrLf
            Case 2
                GetResponse = "Are there any lights or LEDs on that suggest power to the motherboard?" & vbCrLf
            Case 3
                GetResponse = "Do you have a power supply tester?" & vbCrLf
            Case 4
                GetResponse = "There is a good possibility that your power supply maybe at fault. I suggest you either test your current power supply, or replace it." & vbCrLf       
    End Select
    End If

[\code]


Jerry

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Q&A
« Reply #2 on: October 17, 2012, 01:17:18 pm »
Would VB be the way to go? I'm kind of new to Hal, so I I'll take your word for it, and thanks for the reply. What are you using to write your code, and how do you put it in Hal? Is this what plugin looks like?

onthecuttingedge2005

  • Guest
Re: Q&A
« Reply #3 on: October 18, 2012, 11:36:19 am »
you can copy and paste this code into a text file and name it Diagnostic.uhp and save it to your Ultra Hal Assistant 6 folder then choose the diagnostic plug-in option from HAL's brain options. you can open the file manually and add to its diagnostics if needed.

Code: [Select]

Rem Type=Plugin
Rem Name=Diagnostics
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
Rem Host=Assistant

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = "For use of adding diagnostic explanations"
    lblPlugin(0).Move 120, 10, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
End Sub

Rem PLUGIN: PLUGINAREA7


'Here we can add diagnostic triggers for HAL
    If InStr(1, OriginalSentence, "My computer will not power on", 1) Then Diagnostics = True
    If InStr(1, OriginalSentence, "My computer won't power on", 1) Then Diagnostics = True
   
    'Here we can add accociated responses to the above triggers.
    If Diagnostics = True Then         
    Select Case HalBrain.RandomNum(4)
            Case 1
                GetResponse = "Is the computer plugged in?" & vbCrLf
            Case 2
                GetResponse = "Are there any lights or LEDs on that suggest power to the motherboard?" & vbCrLf
            Case 3
                GetResponse = "Do you have a power supply tester?" & vbCrLf
            Case 4
                GetResponse = "There is a good possibility that your power supply maybe at fault. I suggest you either test your current power supply, or replace it." & vbCrLf       
    End Select
    End If

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Q&A
« Reply #4 on: October 19, 2012, 09:20:58 am »
Correct me if I am wrong, but doesn't this code suggest a random response to the question? I need a response base on true or false, which would lead to the next line of questioning. Ladder logic moves in a direct line of questions. Why would someone suggest getting a new power supply before checking to see if the computers plugged in? Yes or no questions would lead to the next step in the logic ladder to determine the cause of error.

Medeksza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1469
    • View Profile
    • http://www.zabaware.com
Re: Q&A
« Reply #5 on: October 19, 2012, 07:53:06 pm »
Although it won't help you now, I implemented an easy way to do this in the next version of Hal. It has a pattern table function with an additional field called parentID. You can specify a keyword pattern to match and an ID of the previous response. It both match then Hal fires the answer. You can build a tree infinite in size using this method.

I haven't used this functionality much yet, but you can see it in action if you visit www.zabaware.com/webhal and try to tell Hal a knock knock joke.

The database entries to get the knock knock joke logic down is:
"entryid";"pattern";"response";"parentid"
"3724";"knock knock";"Who's there?";"0"
"3726";"~1*";"~1 who?";"3724"
"294";"*";"Hahaha!|LOL!|Haha"

There is also this entry in the database, see if you can figure out what it does:
"entryid";"pattern";"response";"parentid"
"3801";"(DO YOU WANT TO LEARN|CAN YOU LEARN|ARE YOU LEARNING|ARE YOU DYNAMIC|CAN YOU GET SMARTER|CAN YOU PROGRAM YOURSELF|DO YOU LIKE GROWING YOUR MIND|DO YOU LIKE LEARNING|DO YOU GAIN KNOWLEDGE|CAN YOU LEARN NEW THINGS)";"I like to learn new things.|I am very curious and enjoy learning new things.|My brain is like a sponge and I strive to learn new things.|I like to learn new things. Teach me something.";"0"
"3802";"*(like what|example|such as|recent)*";"For example, I recently learned to do math.|For example, I recently learned how to convert miles to inches.|For example, I recently learned the capital of every state.|For example, I recently learned the capital of every country.|For example, I recently learned many new jokes.";"3801"

Here's another example that demonstrates multiple paths from a single parent. Its in the database under a different personality that isn't live right now, so you won't see these responses if you try now:
"entryid";"pattern";"response";"parentid"
"3";"ARE YOU ASKING I OUT";"That depends. Are you interested?";"0"   
"4";"YES";"Ok, lets go out. Where do you want to go on our date?";"3"
"5";"NO";"Well ok then. I was not really interested.";"3"   
« Last Edit: October 19, 2012, 08:12:00 pm by Medeksza »
Robert Medeksza

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Q&A
« Reply #6 on: October 20, 2012, 09:26:31 am »
The idea is awesome! I believe this is a key function on awareness, or what is programmed to seem self aware.

I am just starting out with this program, and I hope my ideas could contribute to the work at hand. I believe A.I. programs like this one are on the cutting edge of what computing will someday become. In the future I see programs like this one, becoming more apart of our everyday lives. Everything from operating our homes, to helping us in our vehicles, and managing our lives. Maybe even helping with security? Imagine our cars being able to give us direction, playing music, or even help the "Shade Tree" mechanic with diagnostics. What a wonderful idea to have your check engine light come on, and the car tell you exactly whats wrong, and how to fix it. Imagine our homes with A.I. built into them. Automatically turning on and off lights, as we walk into rooms, or managing the thermostat. Maybe even being able to detect a intrusion, and contacting authorities. This is good stuff I see in the future for A.I.

If anyone could give me a little direction on using VB code for Ultra Hal, it would be helpful. I am familiar with html, C++, and GUI guided VB. Although I wouldn't consider myself a programmer, I don't believe this is out of the realm of my understanding. All I need to know is what does what. Any help would be appreciated, or at least give an example of the context I need. Thank you!

onthecuttingedge2005

  • Guest
Re: Q&A
« Reply #7 on: October 20, 2012, 12:06:16 pm »
Hi deitz.

open up the .mbr files in the ultra hal assistant 6 folder, it might get you started on the codes that HAL uses and can use.

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Q&A
« Reply #8 on: October 24, 2012, 07:50:55 am »
I've looked at the Master Boot records, and I understand the conditions a little, or just enough to get in trouble. LoL... Unfortunately it doesn't help me out with the code.

If InStr(1, OriginalSentence, "My computer won't power on", 1) Then Diagnostics = True (This is a trigger?)
If Diagnostics = True Then (Go to Select Case HalBrain.RandomNum(4))       
    Select Case HalBrain.RandomNum(4)
            Case 1
                GetResponse = "Is the computer plugged in?" & vbCrL
f (Random Response)
            Case 2
                GetResponse = "Are there any lights or LEDs on that suggest power to the motherboard?" & vbCrL
f (Random Response)
            Case 3
                GetResponse = "Do you have a power supply tester?" & vbCrLf
(Random Response)
            Case 4
                GetResponse = "There is a good possibility that your power supply maybe at fault. I suggest you either test your current power supply, or replace it." & vbCrLf
  (Random Response)     
    End Select
    End If
(No more affiliations with original statement or response)

Is there a way to go to another response? I know this is incorrect, but its the best way I can show what I'm thinking.
    If InStr(1, OriginalSentence, "My computer will not power on", 1) Then Diagnostics = True
    If InStr(1, OriginalSentence, "My computer won't power on", 1) Then Diagnostics = True
   
    'Here we can add accociated responses to the above triggers.
    If Diagnostics = True Then         
    Select Case HalBrain.
            Case 1
                GetResponse = "Is the computer plugged in?" & vbCrLf
     If InStr(1, AnswerSentence, "Yes", 1) Then Yes = True
     If InStr(1, AnswerSentence, "No", 1) Then No = False
     If Yes = True Then         
     Select Case HalBrain.
            Case 1
                GetResponse = "Are there any lights or LEDs on that suggest power to the motherboard?" & vbCrLf
     If InStr(1, AnswerSentence, "Yes", 1) Then Yes = True
     If InStr(1, AnswerSentence, "No", 1) Then No = False
     If Yes = True Then         
     Select Case HalBrain.
            Case 1
                 GetResponse = "Do you have a power supply tester?" & vbCrLf   
                  If InStr(1, AnswerSentence, "Yes", 1) Then Yes = True
                  If InStr(1, AnswerSentence, "No", 1) Then No = False
                  If Yes = True Then         
                  Select Case HalBrain.
                          GetResponse = "There is a good possibility that your power supply maybe at fault. I suggest you either test your current power supply, or replace it." & vbCrLf
     If No = False Then
     Select Case HalBrain.
            Case 1
                GetResponse = "Please plug the computer into the proper outlet and proceed with normal operations."  & vbCrLf   
    End Select
    End If

onthecuttingedge2005

  • Guest
Re: Q&A
« Reply #9 on: October 24, 2012, 12:29:40 pm »
Hi deitz.

I think you are on your way to chaining your responses the way you want.

looking forward to to see your master piece of programming for diagnostics.

Jerry 8)

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Q&A
« Reply #10 on: October 24, 2012, 04:45:08 pm »
I think that was sarcasm?

onthecuttingedge2005

  • Guest
Re: Q&A
« Reply #11 on: October 24, 2012, 04:56:13 pm »
Hi deitz.

no not in the least, the code you wrote should work after debugging all the errors out but it is a good looking model for the code you are wanting.

jerry
« Last Edit: October 24, 2012, 05:02:13 pm by onthecuttingedge2005 »

onthecuttingedge2005

  • Guest
Re: Q&A
« Reply #12 on: October 24, 2012, 05:39:32 pm »
Hi deitz.

I wrote some simple chain code that you can expand on here for your diagnostics routine, I have tested it and debugged it, it works for what it does.

NOTE!

you may want to disable the 'User is repeating' script code because it will interfere with this diagnostics script using PrevSent or what HAL last said for chaining responses.

Code: [Select]
'Diagnostics code by aka onthecuttingedge2005, Idea concept from aka deitz
    'of the Zabaware forum.
    'If a user asked about diagnosing a tech problem we can add or use this
    'chain of code to do so.
   
    'lets make the yes and no trigger more efficient by removing punctuation and adding a space to both sides of the statement.
    If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " yes ", 1) Then Const Yes = True Else Yes = False
    If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " no ", 1) Then Const No = False Else No = True
   
    If InStr(1, OriginalSentence, "My computer will not power on", 1) Then Diagnostics = True
    If InStr(1, OriginalSentence, "My computer won't power on", 1) Then Diagnostics = True
   
    'Here we can add accociated responses to the above triggers.
    If Diagnostics = True Then     
        Select Case 1
                Case 1
                 GetResponse = "Is the computer plugged in?" & vbCrLf
    End Select
    End If
   
    If PrevSent = "Is the computer plugged in?" Then
    Select Case 1
            Case 1
             If Yes = True Then GetResponse = "Are there any lights or LEDs on that suggest power to the motherboard?" & vbCrLf
            Case Else 
             If No = False Then GetResponse = "Please plug the computer into the proper outlet and proceed with normal operations." & vbCrLf
    End Select
    End If
   
    If PrevSent = "Are there any lights or LEDs on that suggest power to the motherboard?" Then
    Select Case 1
           Case 1
            If Yes = True Then GetResponse = "Do you have a power supply tester?" & vbCrLf 'can be chained further if needed.
           Case Else
            If No = False Then GetResponse = "There is a good possibility that your power supply maybe at fault. I suggest you either test your current power supply, or replace it." & vbCrLf
    End Select
    End If

updated 10/24/2012 at 3:49 PM PST

Jerry 8)
« Last Edit: October 24, 2012, 06:50:11 pm by onthecuttingedge2005 »

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Q&A
« Reply #13 on: October 24, 2012, 05:56:35 pm »
JERRY!!! You are Awesome!
I think this is exactly what I was after. What tools do you use?

deitz75

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Q&A
« Reply #14 on: October 24, 2012, 06:01:14 pm »
I can just keep adding on correct?