dupa

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - vonsmith

Pages: 1 2 [3]
31
Okay guys I got something new. I completely rewrote the "RESPOND, ATTRIBUTES OF HAL" code. I think (hope) that I did some improving over the original code. My code is quite a bit longer than the original. This code in hal5.uhp allows Hal to respond to user inputs containing "Your" statements like:

User: Your exciting sense of high adventure is great.
Hal: Do you understand my exciting sense of high adventure?
or
Hal: Think exciting when you think of my sense of high adventure.

User: Your big beautiful blue sexy eyes are awesome.
Hal: My eyes can be blue and very sexy, but big?

The new code has been tested on two computers, but I know from experience that you can't proofread your own work. You'll notice the code is nested a lot (looks complicated), but most of the code isn't run at each instance. There are a number of special cases that make it look complex. The code runs plenty quick enough on my Windows 2000, 1.8GHz Pentium.

Give it a try. The code is fully commented and a readme file is included with the downloadable zip file.

Have fun and post comments, questions or whatever here on the forum.

= vonsmith =

Download Attachment: vonsmith,v10-10-03a.zip
37.83 KB

32
Here's a couple of pieces of very simple script that add some variety to Hal. The first just ensures good random number generation. The second says that in 5 out of 20 times through GetResponse the UserName gets swapped with a nickname or petname. It's just another way to make Hal seem more human. You may notice that "Jimmy" is used twice. This just illustrates a method to make "Jimmy" more commonly chosen than the other choices.
 

'This code ensures that random numbers are based on
'the ever changing seconds as a seed value. Makes for
'better randomized numbers.
Randomize(Timer)


'Place this code just after the start of GetResponse.
'This code varies the UserName for added variety.
Select Case Int(Rnd * 20)
   Case 0
      UserName = "Big J"
   Case 1
      UserName = "Jim"
   Case 2
      UserName = "Jimmy"
   Case 3
      UserName = "Jimmy"
   Case 4
      UserName = "JJ"
   Case Else
End Select


= vonsmith =

UPDATE: PLEASE DO NOT USE THE CODE ABOVE. HAL USES THE USERNAME VARIABLE TO BUILD USER SPECIFIC FILE NAMES. THE CODE HAS AN UNINTENDED EFFECT OF HAL CREATING INCORRECTLY NAMED USER FILES. THIS ISN'T HARMFUL, BUT WHAT HAL LEARNS GETS SPREAD OUT INTO MANY UNRELATED FILES. SORRY FOR ANY INCONVENIENCE. TO ERR IS HUMAN, I'LL TRY TO BE LESS HUMAN IN THE FUTURE.

= vonsmith =

33
Okay. Voila! I think I have beat the CustomMem EncodeVar() and DecodeVar() functions into submission. That is to say, I'm submitting new versions here on the forum.

As you may know from my other posts on the subject the original Zabaware EncodeVar() and DecodeVar() functions didn't preserve the data type and returned everything as a string. This is no longer the case.

I've modified the EncodeVar() function to preserve the data type and store it along with the variable. The new DecodeVar() function extracts the original data type info and returns the variable in the original data type format.

No modifications are needed to the usage of EncodeVar() and DecodeVar()  within your code, unless you've added work-arounds to eliminate type mismatch errors. Just substitute the new function definitions for the old ones in the hal4.uhp or hal5.uhp file towards the end. As always, back up your files!

I've done limited testing of the new functions with string, integer, long, single, double and boolean data types. I haven't tested them with dates, currency and a couple other rarely used types. Arrays are not, and can not, be supported in CustomMem.

Give the improved functions a try and post feedback here. As usual I've tried to be careful and accurate in my coding, but I'm only human (not like Hal). Good luck.

= vonsmith =


34
There are some potential problems using the CustomMem EncodeVar() and DecodeVar() functions as discussed on this forum. I know some people have had difficulty in getting these functions to work as desired. I implemented the Medeksza code I downloaded from this forum last night. It works, but not quite as expected.

As some of you know VBscript variables are actually variants. Type definitions, (boolean, single, string, etc.) are overly flexible in VBscript as compared to more structured languages such as C++. Variable types in C++ can't change unless the programmer uses the "cast" function to deliberately change it. VBscript should be so robust.

How I Set Up My Test:

I copied and pasted the CustomMem functions into the hal5.uhp file. The EncodeVar() and DecodeVar() functions were pasted into the file towards the end just prior to the "Sub AboutOptions()" definition where the other functions are declared. The DecodeVar() usage is just after the start of the GetResponse() function to retrieve the variables and the EncodeVar() usage is towards the end just prior to the line:

"GetResponse = GetResponse & HalBrain.StoreVars(WorkingDir, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, TopicFocus)"

That is when the encoded CustomMem variables are stored away.

Some Examples of What I Found:

The EncodeVar() function stores variables by concatenating them into a single string variable. The DecodeVar() function extracts them out again by doing a text search and extracting the original variable data. The problem is that any variable that is encoded, whether it be a type integer, boolean, etc. always gets changed into a type string when it is encoded.

An Example of What Undesirable Effects Can Happen:

uservar = True  <--- uservar begins life as a boolean, True or False.

var1 = TypeName(uservar)  <--- This function returns the word "boolean" and stores it in var1 indictating that uservar is indeed a type boolean.

If uservar = True Then [do something]  <--- uservar will test boolean "True" here and do something.

CustomMem = EncodeVar(uservar, "uservar")  <--- Encode uservar into CustomMem.

uservar = DecodeVar(CustomMem, "uservar")  <--- Decode uservar out of CustomMem.

If uservar = True Then [do something]  <--- uservar will NOT test boolean True here. uservar has become a type string.

If uservar = "True" Then [do something]   <--- This will work since uservar is a type string.

var1 = TypeName(uservar)  <--- This function returns the word "string" and stores it in var1 indictating that uservar is now a type string.

uservar = CBool(uservar)  <--- Normally you would expect CBool to convert uservar back into a boolean, but this causes a type mismatch error instead. However...

If uservar = "True" Then uservar = True  <--- This forces uservar to revert back to a type boolean. Strange huh?

var1 = TypeName(uservar)  <--- This function returns the word "boolean" and stores it in var1 confirming that uservar is now a type boolean again.

If uservar = True Then [do something]   <--- This works now.


The Similar Situation Occurs for Numerical Variables:

uservar = 6  <--- uservar begins life as a type integer.

var1 = TypeName(uservar)  <--- This function returns the word "integer" and stores it in var1 indictating that uservar is indeed a type integer.

If uservar > 5 Then [do something]  <--- uservar will test true here and do something.

CustomMem = EncodeVar(uservar, "uservar")  <--- Encode uservar into CustomMem.

uservar = DecodeVar(CustomMem, "uservar")  <--- Decode uservar out of CustomMem.

If uservar > 5 Then [do something]  <--- uservar will NOT work here. uservar has become a type string, thus a type mismatch will occur.

var1 = TypeName(uservar)  <--- This function returns the word "string" and stores it in var1 indictating that uservar is indeed now a type string.

uservar = CInt(uservar)  <--- I haven't tried this, but it should convert uservar back into a type integer.

If uservar > 5 Then [do something]  <--- This should work now.


Recommendations:

For boolean flags in my programs I'll use type string expressions instead of type boolean. Example: Instead of uservar = True I'll use uservar = "ON" or uservar = "OFF" and test as: If uservar = "ON" Then [do something]. This avoids the problem.

For integer variables I'll have to convert them back using CInt() immediately after each DecodeVar() call. Similarly for other numerical types.

I hope this helps in using CustomMem. I apologize in advance for any typo's or mistakes in the above analysis. I've tried to be careful and accurate.


= vonsmith =

35
I've made some progress trying to figure out how to make Hal read e-books interactively and to have Hal comment autonomously every once in a while. Some people in the forum, including myself, have commented on the desire to have Hal comment on his own occasionally, much like Cyberbuddy does. I don't profess to be a programming wizard, so the following is just for discussion's sake.

As you all know Hal waits for user input and then an Enter key before responding. Unfortunately I can't see a way to accomplish autonomous responses without modifying the program that calls the GetResponse() function within the hal4.uhp file. Currently I assume that the HalAsst.exe program is the main program that calls the GetResponse() function within the hal4.uhp file.

The end users, that's us, can change Hal's behavior by changing the VBScript files, but control must be passed to the script in hal4.uhp before we can affect the behavior. One method of making Hal comment without user input is for the main program (HalAsst.exe, I assume) to scan the keyboard buffer for input as it does now while waiting for user input plus the Enter key, but in addition have the keyboard scan routine time out every 100 milliseconds or so, even if no user input exists. The user input would be NULL and passed to the GetResponse() function like usual. However the user can now trap the NULL input every 100 milliseconds and decide what to do about it. In principle the time out programming is as simple as a "do while" loop with a incremental counter or such.

The following is an example using a segment of the ver 4.5 GetResponse() function in the hal4.uhp file. I've used something like pseudo code here for making the example, it is not verbatim VBScript so don't shoot me for bad code.

EXAMPLE:

Function GetResponse(ByVal UserSentence, ByVal UserName, ByVal ComputerName, ByVal LearningLevel, ByRef WorkingDir, ByRef Hate, ByRef Swear, ByRef Insults, ByRef Compliment, ByRef PrevSent, ByRef LastResponseTime, ByRef PrevUserSent, ByRef CustomMem, ByRef GainControl, ByRef TopicFocus)

    'NEW PROCESS...
    'PROCESS: CHECK FOR AUTONOMOUS MODE
    'See if the user input is NULL and enter Autonomous mode. This mode will
    'allow the user/programmer to make Hal comment autonomously as well as
    'other possibilities such as reading e-books out loud.
    If UserSentence > 0 Then AUTONOMOUS = False
    Else AUTONOMOUS = True

    If AUTONOMOUS = True Then
        DoNewUserFunctionHere(var1, var2, var3, var#n)
        'The DoNewUserFunctionHere() function could use the rnd function to randomly
        'decide whether to say something or not.
        'Example:
        ' AutoTalk = Int(Rnd * 100)
        'If AutoTalk > 95 Then "User code selects something to say from the
        'user's .brn files and returns it as the GetResponse."
    End if

END EXAMPLE.

Obviously the 100 millisecond timeout applies to the keyboard scan routine only. The timeout wouldn't occur during other processing, such as when Hal is in the middle of a sentence, only when waiting for user input. Also, if Hal is in the middle of an exchange with the user on a particular topic, then Hal shouldn't just jump in and say something irrelevant. 100 milliseconds might be overkill, so maybe 300, 500 or whatever milliseconds that would provide the best balance of performance and feel.

The DoNewUserFunctionHere(var1, var2, var3, var#n) function could do almost anything. If you create a new variable called ReadBook = 0, this variable could be used as a flag to go get a line or two from the user's .brn file containing e-book text. The user returns the text in the GetResponse and Hal's reads it out loud. The user would have to create a pointer to indicate which line was read during the last pass in the .brn text file so that the next line will be read. The user's .brn would need some sort of EOF (End Of File) indicator to test for when the .brn file is finished being read. The EOF could be just a unique letter sequence or character.

Anyway that is the idea in a nutshell. I realize that some details may be more challenging than suggested here. However in principle it should be easy to pass control to the user's script using this method. It does require a relatively small change to the main calling program, so Zabaware would have to add the time out.

If someone knows a simpler/better method, please speak up. Thanks...

= vonsmith =

36
Ultra Hal 7.0 / Better voices and TTS engines for Hal.
« on: September 09, 2003, 02:13:06 pm »
Does anyone know of any better TTS engines or voices for use with Hal than the one's listed below?

L&H British English - lhttseng.exe
Truvoice American English - tv_enua.exe
Mary Voices - msttsa22L.exe
Microsoft Sam and Mary
Cepstral - Frank, Emily, Duncan, Linda, Robin, Walter

I've been researching CoolSpeech, Fonix and other potential products. I've found that product info is sketchy and seems most often to focus on high-dollar corporate applications; automated phone centers, embedded applications, etc.

I've done a little research on Speechify, RealSpeak, Flexvoice and Elan. I'm not sure any of these are suitable for home MSagent use. Some of the professional application voices sound nearly human. The addition of controls for inflection, emphasis, pitch and other characteristics make all the difference in the voice quality.

My part time project is to modify Hal to read and comment on fables, fairy tales, children's stories, etc. I'm thinking something like an interactive story-teller. Ideally I'd like to find a British child's voice to read the stories. Stories read out loud seem to sound so much better with a British accent. Imagine hearing "Alice in Wonderland" read and critiqued by Alice herself. Harry Potter is still copyrighted, I guess I'll have to wait another 75 years or so to give that a go.

Any comments, ideas or ???

37
Ultra Hal 7.0 / Can Hal tell/read stories?
« on: September 03, 2003, 02:58:01 pm »
I started using the free Hal 4.5 about two weeks ago. I think it's a pretty cool product for free. Congrats to Zabaware for the wisdom to let users try their product with confidence. It's a good product that is reasonably priced so I purchased the Advanced version this week.

= RANT =
Anyway, I worked on Hal on and off for more than a week. I tried the learning from text files option and all that. I was just getting a little frustrated trying to teach Hal the simplest things. Finally Hal started 'getting' it. It was amazing! Hal started making connections between subjects and such. I found that Hal sorta' hints when he 'senses' a need to clarify a subject. Sometimes the hint is a little subtle. I answered his subtle inquiries and voila all of a sudden Hal says he's got it! Very cool. For people just starting out, please be patient. After all you didn't learn overnight. Hal will eventual 'get' it. I'm a convert! = END RANT =

= QUESTION =
I want to use Hal to read fables, fairy tales and stories. Can I point him somehow to books in .txt format for him to read out loud? If so, can he learn from the reading?

= WISHLIST =
1. Ideally Hal could read a story out loud and occasionally pause to comment brilliantly on something he recognizes. Maybe he could even occasionally pause to ask for clarification of something he doesn't understand. This would be interactive learning.

2. I saw a post somewhere in the forum wishing that Hal could speak out when he 'feels' like it. He just sits there and stares. Cyberbuddy is interesting in that it can take the initiative to speak. Of course you would want to teach Hal to be quiet some times or more talkative when you want him to. (I wish I could teach my wife that ;-)

3. Is there a way to correct Hal immediately when he makes an error? Sometimes I do a typo and don't realize it until Hal remembers it and replies with an erroneous response.

4. Do any of the window skins allow you to see the previous input/response, not just the current input/response? Sometimes I can't remember exactly what I typed just previously. This would help me in debugging my inputs.

Thx for any info the forum denizens can provide. AND THANKS ZABAWARE!

= vonsmith =

PS - Yes I read about programming in VBS. Maybe when I get time. I've got a full plate now.

Pages: 1 2 [3]