Hello Boomer,
I'm not aware of a document that is a flow diagram or a summary of Hal's brain.
However, Hal's "brain" is fully annotated. Hal's "brain" is variously called any of the following:
--the "control script"
--the "brain"
--the ".uhp brain file"
--the "Visual Basic Scripting" Hal program
--the "VBS script"
Regardless what you call it, you can look at it by going to the following directory path (or "folder") on a computer running Hal 5:
C:/Program Files/Zabaware/Ultra Hal Assistant 5/
(We use forward slashes here because the forum software can't display backslashes.)
Find the file called "Hal5.uhp" and open it with Microsoft Word, WordPad, Wordperfect, or the Zabaware Brain Editor. It will be easiest to read using the Zabaware Brain Editor, because the Zabaware Brain Editor automatically color-codes the content.
Scrolling down the program, you will find lines of text that begin with the apostrophe ('). These lines are the same as "REM" lines in other programs; lines beginning with apostrophes have no participation in the program; they are there to explain to human readers what the program is doing, and why the programmer wrote the program the particular way that was chosen.
Here is an excerpt from Hal5.uhp:
-------------
'PROCESS: REMOVE PUNCTUATION
'This function removes all punctuation and
'symbols from the User's sentence so they won't
'confuse Hal during processing.
UserSentence = HalBrain.AlphaNumericalOnly(UserSentence)
'PROCESS: MODIFY SENTENCE
'The function, HalFormat, from the ActiveX DLL
'corrects many common typos and chat shortcuts.
'Example: "U R Cool" becomes "You are cool."
'It also fixes a few grammatical errors.
UserSentence = HalBrain.HalFormat(UserSentence)
'PROCESS: REVERSE PERSON
'This function reverses first and second person
'pronouns. Example: The user's statement
'"You are cool" becomes Hal's statement "I am cool."
'Keep this is mind and don't get confused.
'When we are in Hal's brain; In the databases, "I"
'refers to Hal and in the databases, "you"
'refers to the user. This is true whenever we are
'dealing with a user response "processed" by
'Hal's brain.
UserSentence = HalBrain.SwitchPerson(UserSentence)
-----------------
Notice that there are only three lines of active computer code in the above excerpt! All the other extra lines are text, to explain to you, the reader, what the programmer intended and what the program is doing!
-----------------
Here is a line of code and a human-English translation of it:
Code:
GetResponse = "Wow, " & GetResponse
Human-English translation:
The NEW content of the variable memory-bank named "GetResponse" shall be equal to a string of characters containing "Wow, " coupled on the front-end of the PREVIOUS content of the variable memory-bank named "GetResponse."
---------------------
I admit that many annotations are not easy to understand the first time that you see them. The "convention of form" for annotating code is to go on the premise that the reader has some prior knowledge of code, and to just barely say enough to explain the code's purpose. (Otherwise, every annotation might be VERY long!)
By scrolling through the code, you can trace the sequence of events that Hal goes through to process each conversational exchange.
The VBS code is executed from top to bottom every time you press the "enter" key (during a keyboard conversation).
VBS does allow loops and calls to subroutines, but there aren't an excessive number of them in Hal.
Over the past several years I've made many postings on this forum explaining various functions and routines in VBS and Hal, and you can find all of them by using the forum search for "Ferguson." I've also recommended a book that I think is extremely helpful. VonSmith has also posted web links for free educational documents, and excellent programming advice.
I get a lot of messages from people who would like to read and write code, but they get discouraged because they don't understand it instantly. As with many other things, progress comes from interest, practice, and time.
If you give yourself the chance and put in the effort, you will amaze yourself after a while. Things that made no sense at all six months earlier, will eventually seem simple and obvious!
By the way, you will notice from the annotations in Hal's script that many of the activities are labeled PROCESS or SAVE or RESPOND. The items marked PROCESS generally pertain to formatting and manipulating data to make it suitable for Hal's further use; the items marked SAVE usually pertain to storing words, phrases, and sentences in the user's computer in database files; the items marked RESPOND pertain to assembling a potential response for output to the user.
In general, Hal's overall strategy works something like this:
1. PROCESS: The user's sentence is re-formatted, parsed, and analyzed to see if nouns, adjectives, phrases, pronouns, and special topics should be extracted, and if special "triggers" (such as for greetings, insults, goodbyes, math problems, capital city recall) should be activated.
2. RESPOND: Databases are searched to find candidate responses; the criteria for selecting responses includes similarity to previous statement/response patterns, whether the response would be a repetition of a previous response, and how "relevant" the response is (Zabaware has an algorithm for "scoring" the number of matching words, and the number of matching words in the same sequence-pattern). The "best" response is selected. Random-number-generation is used to create some word and sentence variety.
3. SAVE: All the words, phrases, sentences, and inter-sentence relationships are saved to a wide variety of different databases for future use.
There is a reason that the SAVE activity usually comes after the RESPOND activity. It is because we often want to avoid Hal using the most-recent user input remark word-for-word as the response (if we compare a sentence to itself, it's going to get a high "score")! By waiting to respond, Hal won't "see" that remark in his databases until the next round of conversation.
There are some exceptions to the above. For instance, Hal can paraphrase the user's current remark sometimes. But generally, as you read the script, you will tend to see the PROCESS activities clustered earlier in the script, the RESPOND activities mostly toward the middle of the script, and the SAVE activities mostly toward the end of the script. The exact sequence of activities is the result of a lot of thought and testing.
I hope this helps you in what you are looking for, and I strongly urge you to search the forum for the older tutorials and responses on Hal's programming and VBS programming.
Have a great day!
Sincerely,
Don