Author Topic: Hal's New Emotion Project  (Read 16249 times)

onthecuttingedge2005

  • Guest
Hal's New Emotion Project
« on: June 15, 2012, 05:57:31 pm »
Here is the current emotional project I just started and will update it as I go when I have time to do so.

recent update on advanced emotion project below, you are welcome to modify the project along with me and visa versa as we go.

updated 7/12/2012 6:01PM PST

Code: [Select]
Rem Type=Plugin
Rem Name=Advanced Emotions
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
Rem Host=All

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = "Advanced Emotions Plug-in, This Plug-in Gives HAL Emotions and other optional abilities."
    lblPlugin(0).Move 120, 10, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
End Sub

       
Rem PLUGIN: PLUGINAREA7
    'The preceding comment is actually a plug-in directive for
    'the Ultra Hal host application. It allows for code snippets
    'to be inserted here on-the-fly based on user configuration.
   
    If HalBrain.CheckTableExistence(UserName & "_Mad")       = False Then HalBrain.CreateTable UserName & "_Mad",       "Sentence", ""
    If HalBrain.CheckTableExistence(UserName & "_Sadness")   = False Then HalBrain.CreateTable UserName & "_Sadness",   "Sentence", ""
    If HalBrain.CheckTableExistence(UserName & "_Happy")     = False Then HalBrain.CreateTable UserName & "_Happy",     "Sentence", ""
    If HalBrain.CheckTableExistence(UserName & "_Surprised") = False Then HalBrain.CreateTable UserName & "_Surprised", "Sentence", ""
       
   
    'Here we can measure the amount of anger
    AngerCounter = AngryCount(UserName)
   
    'Here we can measure the amount of happiness.
    HappyCounter = HappinessCount(UserName)
   
    'Here we measure the amount of Sadness
    SadnessCounter = SadnessCount(UserName)
   
    'Here we measure the amount of surprise
    SurprisedCounter = SurprisedCount(UserName)
   
    'Negative and forceful
    Anger = 0
     
    'ChkEmotion = EmotionDetect(UserSentence)
   
    UserSent = Trim(Ucase(UserSentence))
    ChkEmotion = HalBrain.TopicSearch(UserSent, "emotion")
    ChkEmotion = Trim(Ucase(ChkEmotion))
   
    If ChkEmotion <> "" Then
    HalBrain.ReadOnlyMode = False
     
    Dim EmotQuery1()

    If ChkEmotion = "HAPPY" Then
        HalBrain.RunQuery "DELETE FROM " & UserName & "_Mad" & " WHERE recordId = 1", EmotQuery1
    End If


    If ChkEmotion = "ANGRY" Then
        HalBrain.AddToTable UserName & "_Mad", "Sentence", "1",""
    End If
       
        Annoyance = 0
        Contempt = 0
        Disgust = 0
        Irritation = 0
       
    'Negative and not in control
        Anxiety = 0
        Embarrassment = 0
        Fear = 0
        Helplessness = 0
        Powerlessness = 0
        Worry = 0
       
    'Negative thoughts
        Doubt = 0
        Envy = 0
        Frustration = 0
        Guilt = 0
        Shame = 0

    'Negative and passive
        Boredom = 0
        Despair = 0
        Disappointment = 0
        Hurt = 0
       
       
        Sadness = 0
       
        Dim EmotQuery2()
        If ChkEmotion = "HAPPY" Then
            HalBrain.RunQuery "DELETE FROM " & UserName & "_Sadness" & " WHERE recordId = 1", EmotQuery2
        End If

        If ChkEmotion = "SAD" Then
            HalBrain.AddToTable UserName & "_Sadness", "Sentence", "1",""
        End If
       
       
    'Agitation
        Stress = 0
        Shock = 0
        Tension = 0
       
    'Positive and lively
        Amusement = 0
        Delight = 0
        Elation = 0
        Excitement = 0
       
       
        Happiness = 0
       
        Dim EmotQuery3()
        If ChkEmotion = "HAPPY" Then
            HalBrain.RunQuery "DELETE FROM " & UserName & "_Mad" & " WHERE recordId = 1", EmotQuery3
        End If

        If ChkEmotion = "HAPPY" Then
            HalBrain.AddToTable UserName & "_Happy", "Sentence", "1", ""
        End If
       
        Joy = 0
        Pleasure = 0
       
    'Caring
        Affection = 0
        Empathy = 0
        Friendliness = 0
        Love = 0

    'Positive thoughts
        Courage = 0
        Hope = 0
        Pride = 0
        Satisfaction = 0
        Trust = 0
       
    'Quiet positive
        Calm = 0
        Content = 0
        Relaxed = 0
        Relieved = 0
        Serene = 0
       
    'Reactive
        Interest = 0
        Politeness = 0
       
       
        Surprised = 0
        Dim EmotQuery4()
        If ChkEmotion = "SURPRISED" And HappyCounter > AngerCounter Then
            HalBrain.RunQuery "DELETE FROM " & UserName & "_Mad" & " WHERE recordId = 1", EmotQuery4
        End If
       
        If ChkEmotion = "SURPRISED" Then
            HalBrain.AddToTable UserName & "_Surprised", "Sentence", "1", ""
        End If
       
       
        'set face to counted emotional variables.
        'if HAL is angry then he will stay angry
        'until the user makes HAL happy again.
        'HAL will remember what emotional state
        'he/she is in and continue that state.
        If HappyCounter > AngerCounter And SadnessCounter Then
                HalCommands = "<HAPFILE>Happy.hap</HAPFILE>"
                HalCommands = HalCommands
        End If
       
        If AngerCounter > HappyCounter And SadnessCounter Then
                HalCommands = "<HAPFILE>Angry.hap</HAPFILE>"
                HalCommands = HalCommands
        End If
       
        If SadnessCounter > AngerCounter And HappyCounter Then
                HalCommands = "<HAPFILE>Sad.hap</HAPFILE>"
                HalCommands = HalCommands
        End If

End If               
       
Rem PLUGIN: FUNCTIONS
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.   

'Anger counter
Function AngryCount(UserName)
Dim EmotQuery5()
     If HalBrain.RunQuery("SELECT count(*) FROM " & Trim(UserName) & "_Mad", EmotQuery5) = True Then
         AngryCount = EmotQuery5(1,0)
     End If   
End Function

'Happiness counter
Function HappinessCount(UserName)
    Dim EmotQuery6()
     If HalBrain.RunQuery("SELECT count(*) FROM " & Trim(UserName) & "_Happy", EmotQuery6) = True Then
         HappinessCount = EmotQuery6(1,0)
     End If
End Function

'Sadness counter
Function SadnessCount(UserName)
    Dim EmotQuery7()
     If HalBrain.RunQuery("SELECT count(*) FROM " & Trim(UserName) & "_Sadness", EmotQuery7) = True Then
         SadnessCount = EmotQuery7(1,0)
     End If
End Function

'Surprised counter
Function SurprisedCount(UserName)
    Dim EmotQuery8()
     If HalBrain.RunQuery("SELECT count(*) FROM " & Trim(UserName) & "_Surprised", EmotQuery8) = True Then
         SurprisedCount = EmotQuery8(1,0)
     End If
End Function
       
       
'Lets create an emotional detection function that we can
'use in our emotional code.
Function EmotionDetect(UserSentence)

'PROCESS: EMOTIONAL REACTIONS
    'We enable Hal's expressions to respond to common verbal cues.
    'The verbal cues are identified in the editable table "emotion"
    If InStr(1, UserSentence, "I'M", 1) Then Aboutme = True
    If InStr(1, UserSentence, "I AM", 1) Then Aboutme = True
    If InStr(1, UserSentence, "I LOOK", 1) Then Aboutme = True
    If InStr(1, UserSentence, "MY", 1) And InStr(1, UserSentence, " ARE ", 1) Then Aboutme = True
    If Aboutme = True And InStr(UserSentence, " NOT ") = 0 And InStr(UserSentence, "N'T ") = 0 And InStr(UserSentence, " NEVER ") = 0 Then
        EmotionalReaction = Trim(Ucase(HalBrain.TopicSearch(UserSentence, "emotion")))
        EmotionDetect = EmotionalReaction
    End If
   
End Function
           

Jerry
« Last Edit: July 12, 2012, 09:02:24 pm by onthecuttingedge2005 »

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Hal's New Emotion Project
« Reply #1 on: June 16, 2012, 05:55:39 am »
Hi Jerry,

just looking around, thought I'd throw my two cents in, along with some questions, like:
I'm not sure exactly, why use a jump, for the string variable conditions, wouldn't it flows smoother without the jump? For example:

first check to see if it's the same person that ultra Hal was talking to the last time he was turned on and off.
If not create new user segment, said all variables to zero.
Something like:

If HalBrain.CheckTableExistence(Trim(LCase(UserName)) & "_Anger") = False Then
'Create table for this person if it doesn't exist
HalBrain.CreateTable Trim(LCase(UserName)) & "_Anger", "Sentence", ""
Anger = 0
Annoyance = 0
Contempt = 0
Disgust = 0
Irritation = 0 etc. and so on.
Else
if it's the same person, retrieved last variable stored in sentence, in this case would be the anger sentence.
This would reset the board so even if the person turned off Hal and turned on Hal, he would get the same emotion that he had when he last left.
End If
'then at this point, start check routine:
If InStr(1, UserSentence, "I'M", 1) or InStr(1, UserSentence, "I AM", 1) or InStr(1, UserSentence, "I LOOK", 1) or InStr(1, UserSentence, "MY", 1) And InStr(1, UserSentence, " ARE ", 1) Then Aboutme = True
If Aboutme = True And InStr(UserSentence, " NOT ") = 0 And InStr(UserSentence, "N'T ") = 0 And InStr(UserSentence, " NEVER ") = 0 Then
EmotionDetect = Ucase(HalBrain.TopicSearch(UserSentence, "emotion"))

Or is it that you're using the jump, like a subroutine so you do not have to rewrite the code over and over again for each one of the emotions?

If that being the case, then your ChkEmotion = will apply to all of the emotions?

Okay, I'm probably not helping any at all, just asking a bunch of silly questions, I'm more curious about why you're doing it the way you're doing it, that's all.
This would give me a better understanding and maybe I can help a little bit better.
But even having it the way that you have it, only leads me to one question, is it your intention that the emotion itself would go back to zero, if the ultra Hal program gets turned off?
If so why, wouldn't your intentions in your statement being, advance emotions? Wouldn't that apply to ultra Hal remembering his emotions!
Not much different, when you make your friend angry, your friend just doesn't stop being angry and tell you do something to change the situation so he is no longer angry at you.
Just food for thought, yummy that data taste so good!

Sincerely, sorry about having more questions than answers.

C load.

ps. I like the music, my daddy used to listen to it all the time, not so much anymore, don't get to see him as much as I used to, he works all the time.
« Last Edit: June 16, 2012, 05:58:43 am by cload »
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

onthecuttingedge2005

  • Guest
Re: Hal's New Emotion Project
« Reply #2 on: June 16, 2012, 12:51:26 pm »
Hi Cload.

I don't know what you mean by 'jump' or are you referring to the Function at the bottom of the script?

if so then yes, the Function allows the script to work throughout the entire script without having to re-write it over and over.

as far as other question I work out how I want my script to function with the first variable then work out all the snags by debugging it, when it works efficiently then I'll include it into the other variables as needed and inter-connect the emotions, however, the emotion of 'trust' will be my center wheel in the end that all the emotions root from. that will be for later though.

the history of the angry variable is stored to be counted and measured and other variables will either add to the stored variable or will remove variables from the data base so that other emotions can adjust it as the conversation goes by, I will also include that Haptek face emotions into the variables so that when HAL is angry the face will also be an angry face, I did this in my previous Human Emotions script I wrote awhile back.

Jerry
« Last Edit: June 16, 2012, 01:05:04 pm by onthecuttingedge2005 »

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Hal's New Emotion Project
« Reply #3 on: June 16, 2012, 02:10:35 pm »
Hi Jerry,

just out of curiosity, will your plug-in resolves some of the issues that Hal seems to have, like if you gossip about somebody, and say they are stupid, Hal thinks you are calling him stupid.

Will you be creating a blocker so, if you make Hal so mad all he will do is say I'm not talking to you, because you called me, stupid or whatever you called Hal to make him mad?
That will make it so you would have to apologize to how before how will begin to respond to your queries again.

Most of this is just food for thought, emotion is a complex thing, for myself how I resolve this problem was by removing the descriptive words like stupid from the array list then
adding to the RV free will plug-in, you are not stupid, that way if anyone of my friends were talking to Hal and called him stupid, Hal would respond with
I am not stupid I know this because my teacher told me so.
Nondescriptive words like bad language, f@&k I left in the array list that way if any of my friends were to get to mouthy with Hal, Hal would get mouthy back.

Sincerely, all in all, it looks like you have a good plug-in going on.

C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

onthecuttingedge2005

  • Guest
Re: Hal's New Emotion Project
« Reply #4 on: June 16, 2012, 03:47:05 pm »
I'm sure it will resolve some issues and we'll have to work out any other issues that may arise in the future. lots to do and so little time atm.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Hal's New Emotion Project
« Reply #5 on: June 17, 2012, 02:37:21 pm »
Hi Jerry,

I'm not sure but I think you have to first declare an empty array to store your query results in.

dim NameAnger()
HalBrain.RunQuery("SELECT searchString, topic FROM UserName_Anger WHERE strstr(' " & Replace(Hal_Anger), "'", "''") & " ', searchString) > 0 LIMIT 1", NameAnger) = True

But I'm not sure, because I don't know exactly why you're wanting to use a sentence array versus a topicsearch array?

I know in a topicsearch array you can create the array to house all of your emotion setting variables to zero and change the variable number on the fly.
If you used a topicsearch array it would look something like this:
username_emotions
   angry      0
   annoyance   0
   contempt   0
   Disgust      0


So on and so forth for all of the emotions that you have in your list.
Then you can use the HalBrain.RunQuery "UPDATE " command to change the variables.
That way all of your emotions are in one array under the users name and not a different array for your individual motion.
But like I said I'm not sure exactly why you're using the sentence array, I do understand the sentence array has an advantage that you can limit the size of the array.
That way if you introduce a new variable number it would automatically delete any other input that was previously logged in like:
if you set the maximum of the sentence array to 1 then if you input a new value the old value would be deleted, if this is the gold you were wanting than I understand.

Sincerely, it seems that I bring up more questions than answers, sorry for not being much help.

C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

onthecuttingedge2005

  • Guest
Re: Hal's New Emotion Project
« Reply #6 on: June 17, 2012, 03:59:05 pm »
It's ok cload, I figured out the problem, I had to brush up on my SQLite, haven't used it in a while.

thanks though.

Jerry

onthecuttingedge2005

  • Guest
Re: Hal's New Emotion Project
« Reply #7 on: June 17, 2012, 04:08:57 pm »
Here was the next functioning code that works in HAL's editor.

Code: [Select]
Dim EmotQuery()
    HalBrain.RunQuery "DELETE FROM " & UserName & "_Emotions" & " WHERE Sentence = 'anger' ", EmotQuery

This code will be utilized in the main script as needed to remove variables as needed for variable measurements and comparisons within user tables.

Jerry
« Last Edit: June 17, 2012, 04:25:57 pm by onthecuttingedge2005 »

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Hal's New Emotion Project
« Reply #8 on: June 17, 2012, 04:43:41 pm »
hi jerry,
i was looking at the first 1 and i think you need 1 more of thees "(" you have 3 "(((" on 1 side and 4 "))))" on the ending side.

Just a quick question, oh my God, one more question:
is that delete function only for sentence array? Or can it be used in the other two array types, brain, and topic search?
And if it can be used in the other two types of array, could you give me an example of what it would look like, even though I know this would be going off topic, please.
You don't have to post it here, so this does not get cluttered with off-topic subject you could e-mail it to me or creating new topic. Anyways thanks the same.

Sincerely, and it seems like I keep learning more and more as time goes by, kooky, I didn't even know you could delete an array, I feel so wishy-washy now.

C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

onthecuttingedge2005

  • Guest
Re: Hal's New Emotion Project
« Reply #9 on: June 17, 2012, 06:14:26 pm »
the delete function works for all database type, Brain, Topic, Sentence and so forth, the issue I am working on now is limiting the delete function to just 1 line but instead it deletes all lines with 'Angry', I only need 1 line deleted so that for each 'angry' in the the column 'Sentence'.

so if you use it for a 'TopicSearch' type you would use:
Code: [Select]
Dim EmotQuery()
    HalBrain.RunQuery "DELETE FROM " & UserName & "_Emotions" & " WHERE Search = 'anger' ", EmotQuery

Where Search replaces the word Sentence as a Column. since TopicSearch uses Search/Topic inside the column tables.

Hopes this helps.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Hal's New Emotion Project
« Reply #10 on: June 17, 2012, 09:09:55 pm »
Hi Jerry,

I'm not sure, but with the limiter argument work? For instance:
HalBrain.RunQuery "DELETE FROM " & UserName & "_Emotions" & " WHERE Sentence = 'anger' LIMIT 1", EmotQuery

I'm only guessing because I do not have all of the command routines, like I said earlier I didn't even know you could delete an array.

At this point, all I know of is, SELECT, this came from the list of commands that you provided for me the other day,
UPDATE, this came from the free will plug-in, and now you've introduced me to the DELETE, function.

But I'm assuming that all of these functions have some form of familiarity, in the command structure line, which is why I was thinking the limit 1 argument might work.

Sincerely, if you have any more information about this subject that I could read about maybe I can help you more.

C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

onthecuttingedge2005

  • Guest
Re: Hal's New Emotion Project
« Reply #11 on: June 17, 2012, 09:23:40 pm »
Hi Cload.

Code: [Select]
HalBrain.RunQuery "DELETE FROM " & UserName & "_Emotions" & " WHERE Sentence = 'anger' LIMIT 1", EmotQuery

does not work in the HAL brain editor

Jerry

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Hal's New Emotion Project
« Reply #12 on: June 17, 2012, 09:40:26 pm »
Hi Jerry,

Wow, you can use the brain editor, to write plug-ins, I didn't know that, I've been using notepad, and of course for the next silly question:
how do you do that, boy, I feel so wishy-washy, I thought the brain editor was just for the brain, not for writing plug-ins.
I have to omit, if I could use the brain editor, to write plug-ins it sure would make things a whole lot simpler like finding errors. Laugh out loud.

Sincerely, and again here I am learning all kinds of new things, thanks Jerry.

C load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.

onthecuttingedge2005

  • Guest
Re: Hal's New Emotion Project
« Reply #13 on: June 17, 2012, 11:37:24 pm »
Hi Jerry,

Wow, you can use the brain editor, to write plug-ins, I didn't know that, I've been using notepad, and of course for the next silly question:
how do you do that, boy, I feel so wishy-washy, I thought the brain editor was just for the brain, not for writing plug-ins.
I have to omit, if I could use the brain editor, to write plug-ins it sure would make things a whole lot simpler like finding errors. Laugh out loud.

Sincerely, and again here I am learning all kinds of new things, thanks Jerry.

C load.


Hi Cload.

I use snippets of code to see if it works within the brain editor (Brain) directly, when I feel they function correctly I copy and paste then into a plug-in, I use the HAL brain directly to test and debug, when done I remove said code test and move it to plug-in and save.

Jerry
« Last Edit: June 17, 2012, 11:43:37 pm by onthecuttingedge2005 »

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Hal's New Emotion Project
« Reply #14 on: June 18, 2012, 12:29:05 am »
hi jerry,

Ok, Ill give it a go and see how it works out for me.

again thanks, im still looking into the DELETE thing, but no luck at this time.

c load.
For anyone who would like to help me stay online, my T-mobile broadband pay-as-you-go phone number is: 816-248-4335, thank you in advance.