Steve,
You had a question about the following line in Enhanced_Main.brn:
" OPEN THE PROGRAM","","","<RUNIT>","","",1,#TRUE#,#FALSE#,"</RUNIT>"
Yes, the RUNIT command passes the file name to windows for execution through a function of a DLL file. These are commands that Robert Medeksza identified as useful, and then created. The commands emerge from the script as part of Hal's response. The .dll filters them out (so Hal doesn't speak them) but uses the commands.
You may have noticed that different .brn database files have different data formats.
The "random" files simply have words, phrases, or sentences with a line break introducing each one. As the name implies, the .dll can access the file and pick one of the entries at random.
It is entirely feasible to write and edit the "random" files on any text editor.
The "associative" files have words, phrases, or sentences in a specific paired-relationship, which is as follows:
@This would be a sentence that Hal might speak.
THESE WORDS MIGHT TRIGGER HAL TO SPEAK THE ABOVE
@Here is another sentence that Hal might speak.
HERE ARE WORDS THAT MIGHT TRIGGER HAL TO SPEAK THE ABOVE
(There should be an "@" sign at the beginning of each of the sentence-case sentences above, and each of the ALL-CAPS sentences should begin with one blank space. The forum program might corrupt these or filter them out.)
Notice that in the "associative" files, the potential sentence is always first, following the "@" sign, and the corresponding trigger words follow.
Hal automatically builds associative databases, relating the user's current statement to Hal's previous statement, and/or to the words in the user's current statement. When Hal uses an associative database, he scans the entire file, and selects the best match. If Hal uses the file twice in a row, he selects the second-best match from the entire file.
It is possible to write and edit the associative files on any text editor, as long as you maintain the paired-relationship pattern, and don't begin or end the file with any extra line breaks (that would corrupt the file).
By far the most complicated database format is the specific-recall files. The Enhanced_Main.brn file is a specific-recall file.
Hal stores trigger phrases in the specific-recall files, and if an exact match occurs for one of those phrases, Hal will use it to respond. Each line in a specific-recall database as actually an "array," which is a set of different items (or "arguments") set apart by commas, which a function can understand and use. Here is a special annotated example of one of the arrays:
" 1ST TRIGGER PHRASE "," OPTIONAL SECOND TRIGGER PHRASE (IF USED, BOTH TRIGGER PHRASES MUST BE FOUND) "," OPTIONAL PHRASE TO CANCEL TRIGGER "," First of three possible Hal responses. "," Optional second of three possible Hal responses. "," Optional third of three possible Hal responses. ",2,#FALSE#,#FALSE#," Optional additional response words. "
If both true/false flags are FALSE, the array works as described above. If the first flag is TRUE, Hal's comments will include the user's words immediately following the words in the first trigger string, and include the optional additional response words last. The numeral argument may be used to give Hal a relative priority level, from 1 (strongest) to 4 (weakest).
Look closely, and you can see how this logic can "trap" the name of a program, and insert that name in between the two "runit" flags for Hal to use.
In the specific-recall databases, the arrays are each separated by a line break. It is possible to write and edit these files on any text editor, but the exact pattern of the arrays MUST be maintained or the file becomes corrupted and unusable.
Yes, there are other bracketed commands such as <time> and <date> and a few more. Most of the commands don't have the <runit> <runit/> pattern, but some do. For instance, there's a command that works like this:
How can Hal tell a riddle and pause for the answer? <topic> With the bracketed topic command, Hal will hold back the chosen words until after the user's next remark. <topic/>
I don't believe that any of these commands are case-sensitive. To make the script and the databases more human-readable, both Robert and I have tended to put trigger words in all-caps, and Hal responses in sentence-case. However, Robert improved Hal's ability to correctly capitalize proper nouns in version 4. To take advantage of this, I'm going back as time permits, and putting more and more items in sentence-case. I have to be careful, because the corresponding VBS-functions have arguments that must be properly "set" to be case-insensitive when detecting strings.
So, what's really happening, is that the user's remark "open the program paint" is being processed so that Hal's .dll sees it as: <runit> paint <runit/>
Hal makes a list of the apparent program files on the user's computer every time that Hal starts up. If the "runit" routine finds a match for a file name on that list, Hal simply calls to "open" that file, as if you double-clicked on that file name in Windows Explorer. That launches the program.
A flaw in this is that some programs don't have intuitive file-names that run them. In those cases, the user might never say a word that corresponds to the file name that Hal can find.
For this reason, I don't think that it's possible to close a program through Hal as he currently functions.
However, it SHOULD be possible (with a little ingenuity) to open picture files, sound files, or pretty much do anything that could be made to happen by opening a specific file. I would recommend that you experiment to see what works; try putting some obvious files or shortcuts with simple names in Hal's directory and see if he can launch them.
Last but not least, yes, I'm a fan of Short Circuit, and many other movies and television programs that featured artificial intelligence, including the amusing and enjoyable Forbidden Planet (on which Walt Disney Productions helped MGM with the special effects). I also see that either Movies Unlimited or Critic's Choice Video is selling old episodes of the 1960's situation comedy My Living Doll, where Robert Cummings is the computer scientist, and Julie Newmar is the beautiful robot whom he tries to pass off as his niece! The artificial intelligence notion has been around for a long, long time!
Cheers and continuing good luck!
Don
Don Ferguson
traininginc@cortrapar.com
www.cortrapar.com