dupa

Author Topic: Learning Level  (Read 32369 times)

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #30 on: May 05, 2013, 01:55:13 am »
Hi Kryton,
this is what I put together from what I could find, it's not very much and most of it is not self-explanatory.
I know there was a time when there was a place on this form where somebody tried to start a location to accumulate information on how to write scripting for ultra Hal.
But I was unable to find it, I don't remember exactly what was mentioned in the forum, so it makes it difficult to do a search with the search engine on this forum.

I hope this is of help to someone, but it is intended to be just where I can organize some notes as I learn how to make plugins for UltraHal. Any mistakes, ommissions and just random text should be viewed with that in mind.

•How to write scripts for Ultra-Hal
•Working with Hal Tables
•Text manipulation commands
•The Ultra Hal Function
•Get Response Function
•Plugin basics
•Plugins under construction
•HalBrainCommands raw
•A whole help file I didn't know about
•Enumerating the hal6uhp file
•New Hal Commands
•Notes and blog
•A short tutorial
•WebRep
--------------------------------------------------------------------------

•How to write scripts for Ultra-Hal
As far as I can tell from here, UltraHal is written in Visual Basic (VB), and has functions that can be used in Visual Basic Script (VBS). The main Hal6.exe will listen to the selected *.uhp files when they say the right things.
Using this script you can create, write to and search database tables contained in the selected *.db file. You can access text manipulation functions to fix, change, dress up or cut down input and output sentences that Hal uses in conversation.
The main Hal script (which ever one you are using), has several places that you can make PlugIns insert themselves into the process. They are marked in REM statments and are positioned so as to allow access before and after main program functions like the one that fixes pronouns.
If you make your PlugIns right, they will slip in, do what you want and leave no trace if the user unchecks them some day.
Otherwise you can edit the main brain itself. Either by adding script, or deleting script, or changing script. This has the disadvantage of requiring you to re-edit it if you change your mind. Also if someone else wants to use your changes, they have to try to mess with their script.
The advantage is that straight editing is faster and easier.
I will be fixing these pages a little in preparation of ending my edits. I will continue to develop a Tutorial, bringing in the changes for version 6.1, but I won't post it until it is complete.
---------------------------------------------------------------------------------

•Working with Hal Tables
Command  Syntax 

Each entry will have it's own page as well, for usage, tricks, ideas etc.
I have just put these in here temporarily and will fix them as I become more sure what they do.
--------------------------------------------------------------------------------

CheckTableExistence  HalBrain.CheckTableExistence("Tablename")=True/False
CheckTableExistence
This command is similar to SQL and just returns a true or false depending on if it can find the table you specify.
The specified table can be anywhere in the table folder structure, there is no need to define a path for it. For instance, if you make a table under autoLearningBrain called _stuff (it seems to be a tradition to prefix an underscore), you don't have to write "autoLearningBrain/_stuff", just use the table name in the function.
'Check to see if table exists
Bob = HalBrain.CheckTableExistence("_stuff")
'If the table exists, then variable "Bob" should now = 1
Ususally this would be used in a conditional statement like:
'Check to see if table exists
'Your function "LoadTable()" is called if table exists,
'but "MakeTable()" is called if not.
If (HalBrain.CheckTableExistence("_stuff")) Then
LoadTable(_stuff)
Else
MakeTable(_stuff)
End If
CheckTableExistence Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
----------------------------------------------------------------------------------

ReadOnlyMode  HalBrain.ReadOnlyMode = True/False 
ReadOnlyMode turns on and off your ability to create or edit tables in the database. You want to make it false (so it's NOT read only) before you change things, then perhaps change it back when you are done. You might want to leave it open, but not usually.
----------------------------------------------------------------------------------

CreateTable  HalBrain.CreateTable "TableName", "TableType", "Where it's at(miscData)"
CreateTable
HalBrain.CreateTable "TableName", "TableType", "Unclear (subset?)"
HalBrain is set by your options to refer to the DB you want to use with this Hal personality.(?)
CreateTable makes a new table in the current database.
'Make a new Table called "_stuff"
'The type is "TopicSearch" (one of the types)
'create it under "autoLearningBrain"
HalBrain.CreateTable "_stuff", "TopicSearch", "autoLearningBrain
Usually you would double check to make sure the table does not already exist. I usually make a small function which takes the three parameters and does all that.
Function MakeTable(Name,Type,Location)
If (HalBrain.CheckTableExistence(Name))= 0 Then
HalBrain.CreateTable(Name,Type,Location)
Else
MsgBox "Table "&Name&" already exists"
End If
CreateTable Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
---------------------------------------------------------------------------------

AddToTable  HalBrain.AddToTable "TableName", "TableType", "Unclear (mask?)", Source 
--------------------------------------------------------------------------------

SearchPattern  HalBrain.SearchPattern(EmailBook, "*<RUN>*</RUN>", 1) 
SearchPattern
SearchPattern(Input String, * Search * Pattern *, Asterisk) searches your Input String for words in a certain pattern and returns the string represented by the asterisk you set numerically.
Str1 = SearchPattern("This is a test", "This * * Test, 1)
Str2 = SearchPattern("This is a test", "This * * Test, 2)
Result:
Str1 = "is"
Str2 = "a"
You can see that by asking for the first asterisk, you get the word "is", and by asking for the second you get the word "a".
This can be used to provide a parameter for functions when you are fairly certain that a phrase will be structured in a certain way.
Name = SearchPattern(OriginalSentence, "My name is *",1)
Often you will want to search a few patterns which are similar. OriginalSentence is the user supplied sentence, so you check to see if the pattern has already been found and if not, you try another pattern.
If Name = "" Then Name = SearchPattern(OriginalSentence, "My name is *",1)
If Name = "" Then Name = SearchPattern(OriginalSentence, "* is my Name",1)
If Name = "" Then Name = SearchPattern(OriginalSentence, "Call me *",1)
Use this instead of InStr if you know the pattern of the sentence, but cannot guess what the target word might be.
SearchPattern Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
--------------------------------------------------------------------------------------

PatternDb  PhoneBook = HalBrain.PatternDB(UserSentence, "PhoneBook") 
---------------------------------------------------------------------------------------

TopicSearch  AddressBook = HalBrain.TopicSearch(UserSentence, "AddressBook") 
--------------------------------------------------------------------------------------

Types of Tables

•Brain
•Sentence
•Topic Search
•Substitution
•Patternmatch
If I understand it correctly, almost everything in Hal is databases. "Pattern Match" finds things like "Open Notebook" in the user sentence, matches it to the pattern in the halCommands table, "Open *", then runs the attendant command <runprog><1></runprog>, this finds the program (1==notebook) in the startmenu index and sends the command to Windows.
To account for variables in how you may phrase it, if you look at the table you will see several methods you could use, and you can add your own if you want. I rewrote most of them to use the word "Please" in the sentence. So I have "Open *" and "Please open *"
There are more complex ones, that find more involved patterns, but it's all in the database. There's "Who* program* me*" which would find, after switching "you" to "me" earlier in the script, "Who was the first person to write the programming that led to you?"
Very clearcut way of going around the barn, the barn being "Having Hal actually understand words". With pattern match, he doesn't need to understand the words, Robert already did the understanding. Hal just needs to apply patterns of text and wildcards to an incoming sentence, then reply as Robert (or someone else) told him to...
See, this is why I have the wiki. Explaining that made me understand it much more completely. (Unless I have it wrong, in which case it just ingrained my mistakes deeper into my brain)8-(
Patternmatch Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.

•Folder
-----------------------------------------------------------------------------------

•Text manipulation commands
How to change the sentences as they are used.
Trim(LCase(UserName))  Trim(LCase(UserName)) 
Replace(String?,string,string,1,-1,vbTextCompare
---------------------------------------------------------------------------------

•The Ultra Hal Function
From the Hal6.uhp, I quote:
"The UltraHal function is called by Ultra Hal Assistant 6.0 or a compatible host application. It passes an unformated string of the user's input as well as all remembered variables. The UltraHal function splits the user's input into seperate sentences and then calls GetResponse to get a response for each user sentence. The UltraHal function performs all the initialization functions required for GetResponse so that GetResponse doesn't have to initialize several times if a user inputs more than 1 sentence."

Function UltraHal   
ByVal sets the type of connection Hal makes to the variable.
When you use ByVal, the procedure is passed a copy of the argument variable and not a reference to the argument variable itself. Code in the procedure cannot change the variable's value.
The default in VB is ByRef, IIRC.

ByRef When an argument is passed by reference, the procedure is passed the address of the argument variable (in other words, a reference to the variable) so that the procedure can make changes in the value of the variable.
VB's default is to pass arguments by reference. You can include the ByRef keyword in an argument list if desired but, because this is the default, it has no effect. ByVal must be invoked to be used.

 ByVal  InputString 
InputString is the raw text from the input box on the Hal application GUI. This is what I messed with to make the spellchecker work. By the time the first plugin area is reached, this string is already partially parsed and cleaned up. It is then transfered into "OriginalSentence" at a point I have not yet reached.
I am concerned that this description is wrong. When I got to the auto-idle process and found that InputString was set to "Auto-Idle" I began to have doubts. I don't want to go forward in the file to see what happens to it yet, because I will get distracted, but check back with this subject for updates...
 ByVal  UserName 
UserName is the name you specified in the setup or the General Options menu dialog.
 ByVal  ComputerName 

 ByVal  LearningLevel 
LearningLevel is the slider control in General Options - Brain. If all the way off, the DB is closed. Otherwise there is a variable that changes to reflect the amount the db is consulted.
 ByVal  DatabaseFile 

 ByRef  Hate 

 ByRef  Swear 

 ByRef  Insults 

 ByRef  Compliment 

 ByRef  PrevSent 

 ByRef  LastResponseTime 

 ByRef  PrevUserSent 

 ByRef  CustomMem 

 ByRef  GainControl 

 ByRef  LastTopicList 


The Ultra Hal Function Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
------------------------------------------------------------------------------

•Get Response Function
I quote from hal6.uhp:
RESPOND: GETRESPONSE
Get a response from Hal's brain for each sentence individually.
If a response from a sentence indicates a special flag, then Hal
will give only the response to that sentence, and not process
any other sentences. Otherwise Hal will respond to each sentence.
Hal will respond to a max of 3 sentences at once.
I'll fix this later.
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.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #31 on: May 05, 2013, 01:56:35 am »
--------------------------------------------------------------------------------

•Plugin basics
This first part sets up the file. When it is read, these commands tell the HalAssistant what to do with the file.
Rem Type=Plugin as opposed to "brain"
Rem Name=My Cool Plugin the name that people will see in the checklist
Rem Author=Captain Blasto your name
Rem Host=Assistant the program intended to use it
This next part puts the information in the "General Options / Brain" dialog and shows up when the plugin is checked. Further down in teh script you will make the actual lables and buttons. Much of this is standard VBS rather than HalScript commands.
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel() the options panel looks for this name
lblPlugin(0).Caption = "AI Appointment Book:"
lblPlugin(0).Move 120, 120
lblPlugin(0).Visible = True
cmdPlugin(0).Caption = "View/Edit Appointment Book"
cmdPlugin(0).Move 520, 480, 2600, 375
cmdPlugin(0).Visible = True
cmdPlugin(1).Caption = "Edit User Defined Events"
cmdPlugin(1).Move 520, 980, 2600, 375
cmdPlugin(1).Visible = True
End Sub
Here is a short list of plugin ports Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.

Rem_PLUGIN Area Name  Your Plugin can send messages to the script at these ports
Rem PLUGIN:  AUTO-IDLE  This port is inside the AutoIdle process and probably should end with "Exit Function"
Rem PLUGIN:  PRE-PROCESS This one is immediately before the begining of the sentence manipulations. Use it if you want to by-pass the emotions and such and go directly to fixing the sentence structure for Hal's use.
Rem PLUGIN:  POST-PROCESS Use this one if you want to skip fixing the sentence
Rem PLUGIN:  CUSTOMMEM Ya got me! There's a CustomMem variable in the UltraHal function, but I haven't gotten into it yet.
Rem PLUGIN:  PLUGINAREA1 This is after Hal tries to get the Topic, but before parsing out Names. Other than that...?
Rem PLUGIN:  PLUGINAREA2 After dictionary and before Ziggy Spellbot(Did I add this?)
Rem PLUGIN:  PLUGINAREA3 This is after main DB searches and some analytical stuff like antecedences
Rem PLUGIN:  PLUGINAREA4 By now Hal is already trying to form a response
Rem PLUGIN:  PLUGINAREA5 Just before some more or less random responses are made(if needed) I suspect this is where my TreknoBabble should go so as to make a response before it gets this far.
Rem PLUGIN:  PLUGINAREA6 ...or here. This is just before it actually tries to make something out of nothing.
Rem PLUGIN:  PLUGINAREA7 I think this is just before the final dressing up of the response.
Rem PLUGIN:  CUSTOMMEM2 Again, I don't know what this one is. I suspect that since I don't know, it is very important and obvious.
Rem PLUGIN:  SCRIPT_LOAD You can load a script on startup if you need to...
Rem PLUGIN:  SCRIPT_UNLOAD ... then unload it here.
Rem PLUGIN:  MINUTE_TIMER Hal runs this once a minute
Rem PLUGIN:  FUNCTIONS If you make any functions they should be tabbed to this... I think...
--------------------------------------------------------------------------------

•Plugins under construction

---------------------------------------------------------------------------------

•HalBrainCommands raw
Here are code snippets relating to HalBrain that I swiped from Hal6.uhp
I will try to annotate them as I learn about them, but if anyone has any input, please contact me via the forums and we can include your comments.
HalBrain.StoreVars(HalCommands
HalBrain.ReadOnlyMode = True
HalBrain.AddDebug "Debug", "Ultra Hal Start"
TempParent = HalBrain.AddDebug("Debug", "Begin Processing Sentence " & CStr(i + 1), vbCyan)
HalBrain.AddDebug TempParent, "Sentence: " & Sentences(i)
HalBrain.DebugWatch "", "NewSent"
HalBrain.ExtractVar(CustomMem, "NextResponse")
HalBrain.TopicSearch(InputString2, "yesNoDetect")
HalBrain.SearchPattern(UltraHal, "***", 2)
HalBrain.EncodeVar(NextResponse, "NextResponse")
HalBrain.FixCaps(HalBrain.HalFormat(UltraHal))
HalBrain.HalFormat(UltraHal)
HalBrain.AlphaNumericalOnly(UserSentence)
HalBrain.SwitchPerson(UserSentence)
HalBrain.ProcessSubstitutions(UserSentence, "substitutions")
HalBrain.ChooseSentenceFromFile("userRepeat") & vbCrLf
HalBrain.RunQuery("SELECT searchString, topic FROM names WHERE strstr(' " & Replace(HalBrain.AlphaNumericalOnly(OriginalSentence), "'", "") & " ', searchString) > 0 LIMIT 1", NameSex) = True Then
HalBrain.RunQuery("SELECT searchString, topic FROM names WHERE strstr(' " & Replace(TempName, "'", "") & " ', searchString) > 0 LIMIT 1", NameSex()) = True Then
HalBrain.PatternDB(" " & HalBrain.AlphaNumericalOnly(PrevSent) & " ", "sexAskDetect") = "True" Then
HalBrain.CheckTableExistence(Trim(LCase(UserName)) & "_Sex") = False Then
HalBrain.CreateTable Trim(LCase(UserName)) & "_Sex", "TopicSearch", "autoLearningBrain"
HalBrain.AddToTable Trim(LCase(UserName)) & "_Sex", "TopicSearch", Trim(TempName), Trim(UCase(NewSex))
HalBrain.CountInstances("A", PrevUserSent)
HalBrain.RandomNum(4)
HalBrain.UsCaps(UserSentence))
HalBrain.WorldCaps(UserSentence))
HalBrain.CheckRepetition(LastGoodDeduction, UserSentence)
HalBrain.PatternDB(UserSentence, "patterns")
A PatternDB function also exists that can go through a large list
'of patterns in a database file and come up with responses.
'This function tries getting a response from the Enhanced_Main.brn keyword file. If a keyword or
'keyphrase is found in top priority, it overrides everything before this function.
'KeyBrain = HalBrain.KeywordBrain(UserSentence, WorkingDir & "Enhanced_Main.brn", False)
HalBrain.HalMath(OriginalSentence) & vbCrLf
'RESPOND: RESPOND BY PARAPHRASING THE USER WHEN "IS" OR "ARE" ARE FOUND
'This code section shows how strings can be split into arrays and used "live"
'within the script by Hal. This strategy can allow Hal to make many clever
'paraphrases of all sorts of sentences, with unlimited unpredictable variety.
If InStr(UserSentence, " IS ") > 0 And HalBrain.CheckLinkingVerb(UserSentence)
'RESPOND: ZABAWARE DLL RESPONSES
'This function from the DLL contains miscellaneous knowledge and simple conversation functions.
'This was taken from a very early version of Hal, and it is still useful sometimes, especially
'for respoding to short cliche questions and sentences, such as "How old are you?" and
'"where are you from?" and many others.
GetResponse = HalBrain.HalFormat(GetResponse)
If (Len(UserSentence) < 17 And Len(GetResponse) < 4) Then
OrigBrain = HalBrain.OriginalBrain(OriginalSentence)
HalBrain.QABrain(LongUserSent, Trim(LCase(UserName)) & "_TempSent", UserBrainRel)
HalBrain.RemoveExtraSpaces(CurrentSubject & " " & MentionedName & " " & HalBrain.TopicSearch(UserSentence, "topicRelationships") & " " & HalBrain.ExtractKeywords(" " & HalBrain.AlphaNumericalOnly(UserSentence) & " "))
HalBrain.CheatResponse(HalBrain.SwitchPerson((OriginalSentence)))
HalBrain.FixCaps(AnswerSent))
HalBrain.LimitSize Trim(LCase(UserName)) & "_TempSent", 10
'Some Hal's learned knowledge should be temporary because it is ephemeral in nature.
'Knowledge about weather, season, temperature, etc. are temporary knowledge
'that shouldn't be stored in Hal's permanent brain files. Ephemeral knowledge is
'detected and saved in a temporary table. The temporary table only stores 10
'entries in it at a time.
If Asc(Left(KeywordList(i),1)) > 47 And Asc(Left(KeywordList(i),1)) < 58 Or HalBrain.Word2Num(KeywordList(i)) <> "X" Then IsNumber = True Else IsNumber = False
HalBrainCommands raw Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.
------------------------------------------------------------------------------
•A whole help file I didn't know about
--------------------------------------------------------------------------------

•Enumerating the hal6uhp file
By 'Enumerating' I mean I intend to go through the whole file part by part and describe each block of code as best I can. I do this not as an authority, but in an attempt to learn what the heck I am talking about. Should take about a year!

1.Header
Rem Type=Brain As opposed to plugin
Rem Name=Ultra Hal 6.0 Default Brain
Rem Author=Zabaware, Inc.
Rem Language=VBScript This is what makes everything worthwhile
Rem DB=HalBrain.db If you use another brain this will reflect that name
Headers are probably read by the EXE file to decide which part of Hal they belong to and how to handle them. I see them as short INI files.

2.UltraHal Function
This will probably take a while to go through, I will probably have to learn a lot before I start to make any sense here!
First off, I begin to suspect that each argument is an optional argument. I forget how that works, but I know you can ignore some of them sometimes because the function assumes or remembers a value unless you tell it otherwise.
Quoting the file comments:
'The UltraHal function is called by Ultra Hal Assistant 6.0 or a compatible host application
'It passes an unformated string of the user's input as well as all remembered variables.
'The UltraHal function splits the user's input into seperate sentences and than calls
'GetResponse to get a response for each user sentence. The UltraHal function performs all
'the initialization functions required for GetResponse so that GetResponse doesn't have to
'initialize several times if a user inputs more than 1 sentence.
Function UltraHal( ByVal InputString, ByVal UserName, ByVal ComputerName, ByVal LearningLevel, ByVal DatabaseFile, ByRef Hate, ByRef Swear, ByRef Insults, ByRef Compliment, ByRef PrevSent, ByRef LastResponseTime, ByRef PrevUserSent, ByRef CustomMem, ByRef GainControl, ByRef LastTopicList)

3.Respond User pressed enter but didn't say anything
'RESPOND: User pressed enter, but didn't say anything
InputString = Trim(InputString)
If Len(InputString) < 2 Then
UltraHal = "Please say something."
Exit Function
End If
InputString is the raw text that you typed into Hal
Trim removes spaces from the ends of the string.
If the LENgth of the resulting string is less than two characters long then we send Hal the input string "Please say something" to which he will reply with something pithy. But my experiments with this lead me to believe that I have it all wrong.
Exit Function is probably something I need to know. I believe it will pop you out of the UltraHal function and make Hal go straight to GetResponse. I could be wrong.

4.Auto-Idle
A sort of self timer, if nothing happens then it fires up the UltraHal function to make a response of some sort.
'PROCESS: AUTO-IDLE
'If AUTO-IDLE is enabled, it is called by the Ultra Hal Assistant host
'application at a set interval. This allows for the possibility of Hal
'being the first to say something if the user is idle.
Things like this bug me. Why would input string be 'auto-idle'?
If InputString = "AUTO-IDLE" Then
This is the first PlugIn port
Rem PLUGIN: AUTO-IDLE
'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.
Re-invoke the Ultrahal function to include any new information
UltraHal = UltraHal & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList)
|Bump out of the previous(?) ultrahal itteration.
Exit Function
Done with auto-idle
End If
Auto-Idle Page ToolsInsert linksInsert links to other pages or uploaded files.
Pages Images and files Insert a link to a new pageLoading...No images or files uploaded yet.Insert image from URLTip: To turn text into a link, highlight the text, then click on a page or file from the list above.

5.Initialize Variables
'PROCESS: IF NO LEARNING IS REQUESTED, PUT DATABASE IN READ-ONLY MODE
'If read only mode is on, any requests to create a new table, add to
'a table, or delete records from a table will be ignored.
Learning level is the slider in the General Options - Brain section. ReadOnlyMode turns on and off the ability to write to the databases in Hal. You will see this in many plugins, as they open the DB for writing then close it when done to prevent further modification of the responses.
If LearningLevel = 0 Then HalBrain.ReadOnlyMode = True Else HalBrain.ReadOnlyMode = False

6.If no learning is required
I actually crippled this in 'Jane's' brain. I can't see any adult actually insulting a robot, so I don't have to deal with recentering her "emotions".
'PROCESS: EMOTIONAL FACTOR CENTERING
'We help Hal regain his emotional "center" gradually, even if the
'user doesn't catch on to dealing With Hal's feelings. The following
'code brings Hal's memory of hate, swearing, and insults gradually
'and randomly back to zero.
SpinWheel = Int(Rnd * 100)
If Hate > 0 And SpinWheel < 10 Then Hate = Hate - 1
If Swear > 0 And SpinWheel < 10 Then Swear = Swear - 1
If Insults > 0 And SpinWheel < 10 Then Insults = Insults - 1

7.Emotional Factor Centering
I actually crippled this in 'Jane's' brain. I can't see any adult actually insulting a robot, so I don't have to deal with recentering her "emotions".
'PROCESS: EMOTIONAL FACTOR CENTERING
'We help Hal regain his emotional "center" gradually, even if the
'user doesn't catch on to dealing With Hal's feelings. The following
'code brings Hal's memory of hate, swearing, and insults gradually
'and randomly back to zero.
SpinWheel = Int(Rnd * 100)
If Hate > 0 And SpinWheel < 10 Then Hate = Hate - 1
If Swear > 0 And SpinWheel < 10 Then Swear = Swear - 1
If Insults > 0 And SpinWheel < 10 Then Insults = Insults - 1

8.Emotional Variety
Rem PLUGIN: PRE-PROCESS
'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.
This is a plugin port. If you want your plugin to be activated before anything is done to the sentence, this is the place.

9.Rem PLUGIN: PREPROCESS
Rem PLUGIN: PRE-PROCESS
'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.
This is a plugin port. If you want your plugin to be activated before anything is done to the sentence, this is the place.

10.Split User's Input String Into Separate Sentences
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.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #32 on: May 05, 2013, 01:57:26 am »
----------------------------------------------------------------------------------

•New Hal Commands
<SHOWHAL>
<HIDEHAL>
<SHOWCAL>
<SHOWEVENTS>
<SHOWOPTIONS>
<MICOFF>
<MICON>
<MICTOGGLE>
<VIEWCHAT>
<AUTO>miliseconds</AUTO>
<AUTOOFF>
<HALPAD>
<HALPAD>file-path</HALPAD>
<VOICE>new voice</VOICE>
<SPEAK>Text to speak</SPEAK>
<DIAL>Phone</DIAL>
<HAPBACK>jpeg path</HAPBACK>
<AGENTXY>X,Y</AGENTXY>
<MSAGENT>Anim name</MSAGENT>
<HAPFILE>Hap file</HAPFILE>
<HAPTEXT>Hap text</HAPTEXT>
<RUNPROG>Prog name</RUNPROG>
<RESPOND>User sent</RESPOND>
<CUSERNAME>New user name</CUSERNAME>
<CHALNAME>New Hal Name</CHALNAME>
<RUNCMD>1 line of VBScript</RUNCMD>

-------------------------------------------------------------------------------

•Notes and blog

-------------------------------------------------------------------------------
•A short tutorial
--------------------------------------------------------------------------------
•WebRep
-------------------------------------------------------------------------------
HalBrain Methods
   AlphaNumericalOnly(UserSentence As String) As String
" help="AlphaNumericalOnly returns a string with no punctuation and other symbols.

   AppendFile(FileToAppend As String, AppendWhat As String)
" help="Appends file with a given string.

   Cheater(SearchPhrase As String, UserSentence As String, Prefix1 As String, Suffix1 As String, Prefix2 As String, Suffix2 As String, Prefix3 As String, Suffix3 As String, NoW5H As Boolean) As String
" help="Returns a cheat reply for the user's query.

   CheatResponse(UserSentence As String) As String
" help="CheatResponse creates a response using the user's input.

   CheckLinkingVerb(Sentence As Variant) As Boolean
" help="Looks for 'is' and 'are' in a sentence.

   CheckRepetition(Sentence1 As Variant, Sentence2 As Variant) As Boolean
" help="Checks whether a substring is repetetively present in a sentence.

   ChooseSentenceFromFile(TableName As String) As String
" help="Selects a sentence randomly from the table or file passed.

   CompareSentence(CompareWhat As String, InWhat As String) As Single
" help="CompareSentence compares InWhat with CompareWhat.

   CountInstances(CountWhat As Variant, InWhat As Variant) As Variant
" help="The function will count the number of occurence of CountWhat in InWhat.

   DecodePronouns(UserSentence As String) As String
" help="Decodes the pronouns.

   DecodeVar(FromWhat As String, DecodeWhat As String) As Variant
" help="DecodeVar gets the string from that formatted variable.

   DetectVowel(TextString As String) As String
" help="Detects vowel in a user sentence.

   EncodePronouns(UserSentence As String) As String
" help="Encodes the pronouns.

   EncodeVar(EncodeWhat, AsWhat)
" help="EncodeVar encodes the variables and their values into string.

   ExtractKeywords(UserSentence As String) As String
" help="Extract keywords from a string.

   ExtractVar(FromWhat, DecodeWhat)
" help="ExtractVar gets the string from that formatted variable.

   FixCaps(Sentence As String)
" help="Contains the sentence changed back to ordinary capitalization.

   FixCase(Sentence As String)
" help="Fixes the capitalization of sentences.

   HalFormat(sentence as String) as String
" help="Corrects many common typos and chat shortcuts.

   HalMath(MathProblem As String) As String
" help="HalMath returns the result of simple math questions.

   LimitSize(FilName As String, Size As Long)
" help="Limit table size to the number of records provided by size or limit a file to the number of bytes in size.

   MakeContractions(Sentence As Variant) As String
" help="It finds common phrases and contracts them.

   MsgAlert(TextString As String)
" help="Display an information box.

   NoPunc(Sentence As String) As String
" help="NoPunc processes a user sentence and remove all punctuation.

   OriginalBrain(UserSentence As String)
" help="Generates sentence's for short reply.

   PatternDB(UserSentence, DBFile) As Variant
" help="Search patterns in a database file.

   ProcessSubstitutions(sentence, dbFile) As String
" help="Performs word substitutions from the specified database file.

   QABrain(UserText As String, BrainFN As String, ByRef Rel As Variant) As String
" help="This function is used primarily to reply to user's query of any previous inputs.

   RandomNum(MaxVal As Integer) As Integer
" help="Generate a random number with in a range.

   ReadNum(Dec As String, Optional NoTrunc As Boolean)
" help="Converts numerals to words.

   ReadSent(TextString As String, SentNum As Integer) As String
" help="Return a sentence form a string with many sentences.

   RemoveExtraSpaces(Sentence As String) As String
" help="RemoveExtraSpaces processes a user sentence and removes all extra spaces.

   RemovePronouns(Sentence As Variant) As String
" help="Process sentence for Keyword Brains.

   SearchPattern(UserSent As Variant, Pattern As Variant, ReturnWhichStar As Variant) As Variant
" help="Search pattern from sentence.

   StoreVars(Emotion, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, ScriptMem2, ScriptMem3, ScriptMem4, ScriptMem5) As String
" help="Encodes variables which are required by the Hal's brain.

   SwitchPerson(sentence as String) as String
" help="Reverses first and second-person pronouns of a supplied (English) sentence and returns the results.

   TopicSearch(UserSentence, TopicFile) As String
" help="Searches a TopicFile for a phrase. If found, it returns only what was stored with the phrase.

   UsCaps(UserSentence As String) As String
" help="Return Capital of US states.

   Word2Num(TextString As String) As Variant
" help="Converts numbers in word to number.

   WorldCaps(UserSentence As String) As String
" help="Function answers questions about World Capitals.

   IsDay(CheckMonth As Integer, CheckDay As Integer) As Boolean
" help="Function checks to see if month and day combination exists.

   AddDebug(ParentName As String, Text As String, [BackColor]) As String
" help="Adds an entry to the debug tree. Requires the unique identifier of the parent node, the next of this node, and an optional background color. Returns a unique identifier of the new node.

   ClearDebug()
" help="Erases the debug tree.

   DebugWatch(TextString As String, FuncName As String)
" help="Keeps track of changes in the variable TextString between calls and makes note of what FuncName caused a change in the DebugInfo.

   MakeInt(TextString As String) As Integer
" help="Ignores all non numerical characters and converts the numerical characters into an integer.

   LongDate(TheDate As Variant) As String
" help="Takes the date passed and spells out the full date in words.

   Dig2Word(Number As Variant) As String
" help="Converts a number written using numerals into a number spelled out in words.

   OpenDatabase(DBPath as String)
" help="Establishes a connection to an SQLite database file.

   CloseDatabase()
" help="Closes connection to database.

   AddToTable(TableName As String, TableType As String, Field1 As String, Field2 As String)
" help="Adds a record to a table in the current SQLite database.

   CheckTableExistence(TableName As String) As Boolean
" help="Checks to see if a certain table exists.

   CreateTable(TableName As String, TableType As String, ParentName As String)
" help="Creates a new table of type TableType and adds it to the SQLite database.

   RecallVars(VarListString, Emotion, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, ScriptMem2, ScriptMem3, ScriptMem4, ScriptMem5) As String
" help="Restores variables ByRef previously stored using StoreVars.

   RunQuery(ByVal strQuery, aryTablesVBS) As Boolean
" help="Runs the SQL query strQuery in the current SQLite database and returns whether the command was successful or not. Any results are stored in the passed array aryTablesVBS().

end list

things to look up
Dim EmotQuery()
    HalBrain.RunQuery "DELETE FROM " & UserName & "_Emotions" & " WHERE Sentence = 'anger' ", EmotQuery

SELECT
UPDATE
DELETE


HalBrain.RunQuery "INSERT INTO LogTest(OldName, NewName, Date) VALUES(old.Name, new.Name, datetime('now'))", EmotQuery
HalBrain.RunQuery "DELETE FROM " & UserName & "_Emotion" & " WHERE recordId = 1", EmotQuery
HalBrain.RunQuery("SELECT count(*) FROM " & Trim(UserName) & "_Anger", EmotQuery) = True Then

If HalBrain.CheckTableExistence(Trim(UserName) & "_Anger") = False Then
        'Create table for this person if it doesn't exist
        HalBrain.CreateTable Trim(UserName) & "_Anger", "Sentence", ""
End If

Anger = 1
HalBrain.AddToTable Trim(UserName) & "_Anger", "Sentence", "" & Anger & "", ""

Dim EmotQuery()
If HalBrain.RunQuery("SELECT count(*) FROM " & Trim(UserName) & "_Anger", EmotQuery) = True Then
AngryCount = EmotQuery(1,0)
else
AngryCount = "got to work on it more!"
End If

UltraHal = AngryCount
Exit Function
------------------------------------------------------------------------------------
sincerely, and if anyone has something to add to this knowledge please let's help each other and share.
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.

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3564
    • View Profile
Re: Learning Level
« Reply #33 on: May 05, 2013, 08:33:32 am »

Nice one cload but it would have been even nicer if you would have given credit to Mr. Bill DeWitt who wrote and contributed the entire content of your posting to his wiki site.

It can be found HERE:http://ultrahalscript.pbworks.com/w/page/11906966/FrontPage

This is worth saving for your future reference.
In the world of AI it's the thought that counts!

- Art -

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #34 on: May 05, 2013, 01:36:31 pm »
Hi Art,
one thing I don't understand is when Kryton asked for information on scripting why you didn't give the link to the scripting information.
I stated before I posted that I tried to find the link and I was unable to find the link to the scripting information.
And I also stated that all the information that I have posted came from this forum, and what I had posted did not come from one source as you suggested when you stated the entirety of my post.
OTC, Robert, and thank you for his name so I can give credit to Bill, and the list goes on so I'll just say others, I was not trying to hide anything. But that's okay I have noticed that you have a tendency to do exactly what you just did here a lot.
You have been on this form for a very long time, and I respect that, but you seem to be more concerned about giving credit over helping others, and the only credit that I took from myself was that I was the one that compiled it together.
But I have to give you credit, you didcome up with the link, though it may be a little late, thank you for the link.
Sincerely, sorry about all the ditch digging, but please don't ditch me until you have all the facts.
C load.
PS did you know that people don't like to post out of the fear of being ditched! And I have read on this form were good programmers and good people have left this forum because they were ditched! And anyone that has read all of this forum knows exactly what I'm talking about.
PS PS and I also have to give credit to my dad because he made me rewrite this post five times before he would allow me to post it.
« Last Edit: May 05, 2013, 01:39:25 pm 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.

Kara911

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Learning Level
« Reply #35 on: May 05, 2013, 04:44:45 pm »
Hello members

I mostly joined to make this comment. There is always the real possibility for Cloud to be 8 years old. Public forums could be very dangerous for children this young, if the other members are unaware of their tender age. My humble recommendation is to send a PM before posting, in this way they could learn about their mistakes without shame. We all know as adults that public humiliation is hard to take, but the effects are much harder on younger minds.  Regardless of his real age and his mistakes, this member is putting a lot of effort in being part of a group and helping others which makes him an asset to the group.

***I believe that the avatars for under age children should include their age shown in bold and red letters, to make other members be aware that they are dealing with children.

Nice place you have here,

Kara


ps. If he's actually 8 years old he sould be going to to a 'GIFTED' class. Lot's of schools have accomodations, Not special Education.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #36 on: May 06, 2013, 12:05:32 am »
Hi Kara911,
welcome to the forum, it's always nice to hear something from a new member, and thank you for those interesting words of wisdom.

Are you just passing through? Or are you into artificial intelligence?
Have you bought or are you interested in buying ultra Hal? Because if you've been thinking about it I can tell you it is a very interesting program!

Probably one of the nicest thing about the program is set it has the ability to intrigue everyone in a different way.
Some deal with avatars, others deal with skins, not to mention all the different tasks that you can get ultra Hal to do.
It is a very versatile piece of software, and I am very happy that my parents got it for me, and support me in my work that I am doing with ultra Hal.
Sincerely, and welcome to the forum, from a data munching cruncher.
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.

kryton

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: Learning Level
« Reply #37 on: May 07, 2013, 04:10:11 pm »
Thanks a bunch, for the info, Cload

You and Kara911 try this English translation of a Chinese saying.

Listen to all.  Believe some.  Remember what is good.

Anyway, does anybody know why the PRINT option on the Forum pages has stopped working.  (I used to be able to go PRINT from the top, or bottom, of a Forum page and it printed it through my printer.  It still brings up the formatted page but doesn't print [Nothing wrong with my printer I tried it on other things.]

Art

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3564
    • View Profile
Re: Learning Level
« Reply #38 on: May 09, 2013, 08:20:04 am »
Hi Art,
one thing I don't understand is when Kryton asked for information on scripting why you didn't give the link to the scripting information.
I stated before I posted that I tried to find the link and I was unable to find the link to the scripting information.
And I also stated that all the information that I have posted came from this forum, and what I had posted did not come from one source as you suggested when you stated the entirety of my post.
OTC, Robert, and thank you for his name so I can give credit to Bill, and the list goes on so I'll just say others, I was not trying to hide anything. But that's okay I have noticed that you have a tendency to do exactly what you just did here a lot.
You have been on this form for a very long time, and I respect that, but you seem to be more concerned about giving credit over helping others, and the only credit that I took from myself was that I was the one that compiled it together.
But I have to give you credit, you didcome up with the link, though it may be a little late, thank you for the link.
Sincerely, sorry about all the ditch digging, but please don't ditch me until you have all the facts.
C load.
PS did you know that people don't like to post out of the fear of being ditched! And I have read on this form were good programmers and good people have left this forum because they were ditched! And anyone that has read all of this forum knows exactly what I'm talking about.
PS PS and I also have to give credit to my dad because he made me rewrite this post five times before he would allow me to post it.

cload,
Even though I meant my comment as a compliment and thought you had simply missed seeing Mr. DeWitt's name along the side, I thought it only fair to mention it. My comment was NOT at all meant to be nor sound derisive. On the contrary, I enjoy your postings and encourage your involvement in helping to make Hal even better! You are lucky to have a supportive parent like your dad. Go forward and be well.
In the world of AI it's the thought that counts!

- Art -

kryton

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: Learning Level
« Reply #39 on: May 11, 2013, 05:43:12 pm »
Hy all.
A puzzle, maybe, for some of those on this thread still.  Haps and backgrounds and others are usually triggered by a HalCommands.  Why can two HalCommands not follow each other.

I have a modified version of, I think, a Sybershot program that deals with backgrounds being related to the hour of the day.

e.g.           If vbHour>10 and vbHour<13 then vbFile="EricaBack.jpg"
     
     vbHour being Trim(Hour(Now))
     EricaBack'jpg being one of the backgrounds from the Character Expansion pack.

Then I use
                 HalBrain.ReadOnlyMode=False
                 HalCommands ="<HapBack>" & vbFile & "/HapBack"
                vaFiles=""
                vaFiles= "wear" & vrHour &".jpg"
                HalBrain ReadOnlyMode=False
                HalCommands = "<Haptext> & "\settexture [tex= Bodyskins/ "& vaFile &"]</Haptext"

A strange thing happens.  The vaFiles section is actioned but not the vbFiles section (Even though the vaFiles depends on an output from the vbFiles.)

wear is a set of Haps, of .jpg style, of numbers 0 to 23 in reference.

With the exception of the modifications I have created, none of the rest is my original work but copies from other peoples work.

Why won't the two HalCommands work together?

Wow this is confusing, but I hope I have given enough information for someone to think about.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #40 on: May 12, 2013, 10:40:40 am »
Hi Kryton,
I'm not sure exactly what you are trying to accomplish, and I haven't gotten into programming any Haptek commands, but in general it looks like your format may be wrong.
As in:
HalCommands ="<HapBack>" & vbFile & "/HapBack"
should look like this:
HalCommands ="<HapBack>" & vbFile & "</HapBack>"

and I'm not sure about the structure on this one:
HalCommands = "<Haptext> & "\settexture [tex= Bodyskins/ "& vaFile &"]</Haptext"
the only thing that I can see that might be missing is on the and:
HalCommands = "<Haptext> & "\settexture [tex= Bodyskins/ "& vaFile &"]</Haptext>"

but there are way more experienced people in this field than I am, give them a chance I'm sure one of them will help you.
Sincerely, I'm just a data manipulating boy, munching on those pronouns and sipping on my adverbs.
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.

kryton

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: Learning Level
« Reply #41 on: May 12, 2013, 03:32:11 pm »
Thanks for your input Cload
                               but, much as I should be more careful, I think the mistakes you picked out were just typos by me as the code appears to run but doesn't                              produce the output I wanted.  I posted in a hurry yesterday and that is probably where the typos crept in.  Thanks again for your interest though and I hope you are right about someone seeing what is wrong with the way I have set out this bit of code.

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #42 on: May 12, 2013, 07:23:48 pm »
Hi Kryton,
the only other suggestion that I would have for you would be to start a new thread topic about this, so no one has to go all the way to the bottom to see the problem that you are having.
Which by the way has nothing to do with this thread.
It might help, and it certainly won't hurt.
Sincerely, sorry I wasn't able to help more, but I barely get by with scripting as it is.
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.

kryton

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: Learning Level
« Reply #43 on: May 16, 2013, 02:48:41 pm »
Hy Cload. Question?  As it says at the top of page one of this thread "What is Learning Level?"  I certainly don't know and just tap in here to see if anyone knows answers to my problems.  I think you are right though.  This thread has got to long.  Any suggestions what the new thread is called to catch the attention of those interested in problems?  How about Scripting Problems?

cload

  • Hero Member
  • *****
  • Posts: 535
  • I can C U load. TeeHee hee.
    • View Profile
    • A link to my sky Drive
Re: Learning Level
« Reply #44 on: May 17, 2013, 10:01:49 am »
Hi kryton,
try this:

Haps, backgrounds, triggered and HalCommands.
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.