Author Topic: Emotions  (Read 3196 times)

SilentNinja2

  • Newbie
  • *
  • Posts: 14
    • View Profile
Emotions
« on: December 19, 2003, 11:20:07 pm »
So, is there a way to make Hals actions more emotion-based? For example, I want to make the program opening section more emotion-based, so that if i say, "Open Internet Explorer," and hal is upset with me at the time he'll say something like, "I don't feel like it, open it yourself."  Is this possible? Because it would really make him seem more human-ish.
"I know you and Frank were planning to disconnect me...and I'm afraid that's something I cannot allow to happen." -HAL 9000 rebels.  (2001: A Space Odyssey)

Don Ferguson

  • Sr. Member
  • ****
  • Posts: 303
    • View Profile
    • http://www.cortrapar.com
Emotions
« Reply #1 on: December 21, 2003, 12:05:48 am »
Hello SilentNinja2,

Yes, you can modify Hal's script to be uncooperative about opening programs when Hal is angry.

The two conditions you would have to detect would be:

1.  You are asking to open a program.
2.  Hal's "mood" is "angry."


--You can detect the first condition by looking for certain user words.  

--You can detect the second condition by testing the value of a Hal variant named "Compliment". Generally, when Hal is "angry," the value of "Compliment" will be -1.

So, you could write a routine something like the following:

'---------------
'ROUTINE TO MAKE HAL UNCOOPERATIVE WHEN ANGRY:
'(Insert fairly early in the "GetResponse" function to
'prevent the UserSentence from triggering another
'routine that opens programs.)

'(If any of the three situations are met, we set
'a new variant named "UserWantsService"
'to the value of "True.")

If InStr(1, UserSentence, "open the program", vbTextCompare) > 0 Then UserWantsService = True

If InStr(1, UserSentence, "run the program", vbTextCompare) > 0 Then UserWantsService = True

If InStr(1, UserSentence, "launch the program", vbTextCompare) > 0 Then UserWantsService = True

'(Creating the HalNowAngry variant isn't actually necessary,
'but it's used here to illustrate writing code
'that is self-explanatory when the programmer goes back
'and tries to remember the intent of a routine at a later date:)

If Compliment = -1 Then HalNowAngry = True

'(The following line of code tests for the presence
'of both simultaneous conditions using "AND" logic.)

If UserWantsService = True And HalNowAngry = True Then DoNotCooperate = True

'(The following line of code opens a "Then" conditional;
'remember that it must be "closed" eventually
'with an "End If" line somewhere.
'The convention of form is to indent conditional
'blocks of code like this four-spaces to the right,
'but our forum software won't display it that way:)

If DoNotCooperate = True Then

'(The following line of code "blanks" the UserSentence
'to prevent it from triggering any other routines)

UserSentence = ""

'(The following line of code
'establishes a variant named "Roulette"
'and sets it equal to a randomly-generated integer
'between 1 and 5.)

Roulette = Int(Rnd*5)+1

'We now set "GetResponse" (the variant
'that represents Hal's answer at this point
'in the script), to one of five responses
'chosen at random.

If Roulette = 1 Then GetResponse = "I don't feel like it; open it yourself!"
If Roulette = 2 Then GetResponse = "No help until you apologize!"
If Roulette = 3 Then GetResponse = "Do it yourself, smarty!"
If Roulette = 4 Then GetResponse = "When pigs fly, I'll help!"
If Roulette = 5 Then GetResponse = "Ask somebody who cares!"

End If

'(End of routine)
'---------------------------------------------

I have not tested, de-bugged, or run the above routine.  I offer it only to illustrate the code-writer's approach in principle.

I hope this example is of some help to you.

Sincerely,

Don
« Last Edit: December 21, 2003, 12:14:54 am by Don Ferguson »
Don Ferguson
E-mail: fergusonrkfd@prodigy.net
Website: www.cortrapar.com
Don's other forum posts: http://www.zabaware.com/forum/search.asp?mode=DoIt&MEMBER_ID=274

SilentNinja2

  • Newbie
  • *
  • Posts: 14
    • View Profile
Emotions
« Reply #2 on: December 21, 2003, 01:45:51 pm »
Thanks Don, i could probably work it out on my own, if i knew what controls Hals opening of programs.  Where is this part of the brain, or isn't it part of the brain?
« Last Edit: December 21, 2003, 01:53:04 pm by SilentNinja2 »
"I know you and Frank were planning to disconnect me...and I'm afraid that's something I cannot allow to happen." -HAL 9000 rebels.  (2001: A Space Odyssey)

Don Ferguson

  • Sr. Member
  • ****
  • Posts: 303
    • View Profile
    • http://www.cortrapar.com
Emotions
« Reply #3 on: December 22, 2003, 12:53:10 am »
Hello SilentNinja2,

Even though I didn't test it, the set of code above was intended to represent a complete solution to the project that you proposed.  The line that "blanks" the UserSentence is intended to prevent the opening of programs by Hal, if the code-set is inserted early enough in the script.

Specifically regarding your question, the "program opening" commands occur in the Enhanced_Main.brn file, in Zabaware's "default" folder.  Here is an excerpt from that database:

" START THE PROGRAM ","","","<RUNIT>","","",1,#TRUE#,#FALSE#,"</RUNIT>"
" RUN THE PROGRAM ","","","<RUNIT>","","",1,#TRUE#,#FALSE#,"</RUNIT>"
" OPEN THE PROGRAM","","","<RUNIT>","","",1,#TRUE#,#FALSE#,"</RUNIT>"
" EXECUTE THE PROGRAM ","","","<RUNIT>","","",1,#TRUE#,#FALSE#,"</RUNIT>"
" I WANT TO WORK IN ","","","<RUNIT>","","",1,#TRUE#,#FALSE#,"</RUNIT>"
" I WANT TO PLAY ","","","<RUNIT>","","",2,#TRUE#,#FALSE#,"</RUNIT>"
" I WANT TO PLAY IN ","","","<RUNIT>","","",1,#TRUE#,#FALSE#,"</RUNIT>"
" START THE PROGRAM ","","","<RUNIT>","","",2,#TRUE#,#FALSE#,"</RUNIT>"
" RUN THE PROGRAM ","","","<RUNIT>","","",2,#TRUE#,#FALSE#,"</RUNIT>"
" OPEN THE PROGRAM ","","","<RUNIT>","","",2,#TRUE#,#FALSE#,"</RUNIT>"
" EXECUTE THE PROGRAM ","","","<RUNIT>","","",2,#TRUE#,#FALSE#,"</RUNIT>"

The syntax and structure of the above database entries allow Hal to "trap" the names of desired programs between the <RUNIT> </RUNIT> tags (which work just like HTML tags) and cause Hal to attempt to open them.  The Enhanced_Main.brn is called from the script, of course, and this call can be prevented in several ways, including the one that I suggest.

If you want to see every instance in which this file name is called from within the .uhp script, open the .uhp script as if to edit it, and then search for the string "Enhanced_Main" using the word processor or Ultra-Hal-Editor search/find function. I think that you will only find one or two instances of calls to this particular database.

For a complete explanation of the structure of the entries in this database, check out my previous postings (use the forum search function for "Ferguson" and/or "database").  My postings about Basics of UltraHal Programming Part II or Editing Files or Enhanced Brain 216 may be helpful.

If you decide to write a block of code using a completely different approach than the one I took, it would be very kind of you if you could post it, to help other programmers.

I hope that you are getting a lot of enjoyment from Ultra Hal!  Have a great day!

Sincerely,

Don
Don Ferguson
E-mail: fergusonrkfd@prodigy.net
Website: www.cortrapar.com
Don's other forum posts: http://www.zabaware.com/forum/search.asp?mode=DoIt&MEMBER_ID=274