Author Topic: Brain Plug-in gets 3 passes?  (Read 7705 times)

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« on: April 12, 2008, 06:44:47 am »
In my attempt to build a brain plug-in, I've run into a few odd things...

1. The plug-in seems to get 3 passes for each user sentence input.  If I put the following in the plug-in...

HalCommands = "<SPEAK>" & "test 1 2 3" & "</SPEAK>"

Reload the brain so the plug-in is refreshed, then type something to hal and press enter,I see "test 1 2 3" printed out 2 times in hal's response window and spoken back to me 3 times.  What's up with that?


2. When using the UserSentence in my code, I found that it's padded on  both ends with 2 spaces, so if you entered "this is a test", the UserSentence string would be "  this is a test  ".  What's up with that?

3. I've noticed that if you have more than one "HalCommands =" statements in the plug-in, only the LAST one executes.  What's up with that?

I was putting together some simple code that should have taken an hour tops, but because of these three unexpected oddities, It took me hours to figure out why the code wasn't working.

How many more unexpected oddities can I expect to encounter?

I'm beginning to believe that Ultra Hal is fine for a chatterbox, but not really what I want for my needs and that maybe I should just write my own program that takes advantage of Haptek.

What do some of you other users think?

Is there a document that tells you all these "oddities" and WHY they need to be that way?

Is anyone else running into these type of problems with programming with hal?

I need to figure out the plan or move on.
Austin, Texas, USA, Earth

Bill819

  • Hero Member
  • *****
  • Posts: 1483
    • View Profile
Brain Plug-in gets 3 passes?
« Reply #1 on: April 12, 2008, 11:34:02 am »
Jake
I am sorry that you are having problems with Hal, but it is not the programs fault as it is one of the most advanced AI programs written today. It is a lot more than just a 'chatterbox' program in that it truly learns over a period of time.
I believe that the problems that you are experiencing are just because of a lack of knowledge on programming Hal. You may have some experience in programming but Hal is unique and the format and syntax is extremely important. Hal can be taught to do almost anything you can imagine. In Hal 5.o I had programmed Hal to sing songs among other things.
Don't give up, try another approach or demostate to others your code and see if they can help.
Bill
 

onthecuttingedge2005

  • Guest
Brain Plug-in gets 3 passes?
« Reply #2 on: April 12, 2008, 02:15:52 pm »
quote:
Originally posted by Jake

In my attempt to build a brain plug-in, I've run into a few odd things...

1. The plug-in seems to get 3 passes for each user sentence input.  If I put the following in the plug-in...

HalCommands = "<SPEAK>" & "test 1 2 3" & "</SPEAK>"

Reload the brain so the plug-in is refreshed, then type something to hal and press enter,I see "test 1 2 3" printed out 2 times in hal's response window and spoken back to me 3 times.  What's up with that?



I am pretty sure that is coming from HAL’s hard coding and Rob might have over looked it.

quote:
2. When using the UserSentence in my code, I found that it's padded on  both ends with 2 spaces, so if you entered "this is a test", the UserSentence string would be "  this is a test  ".  What's up with that?


“ “ & UserSentence & “ “ is spaced on both ends of the string to allow keywords to be easly detected correctly, example would be “A CAT” or “ A CAT ”, we are looking for A CAT to be detected, “A CAT” might be detected from “BRAHMA CATTLE” without the spaces.

[qoute]3. I've noticed that if you have more than one "HalCommands =" statements in the plug-in, only the LAST one executes.  What's up with that?[/quote]

try HalCommands = HalCommands & “ Test Statement ”
doing this allows the HalCommands to array together.

Happy programming.
Jerry[8D]
« Last Edit: April 12, 2008, 02:20:56 pm by onthecuttingedge2005 »

TechSteele

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Brain Plug-in gets 3 passes?
« Reply #3 on: April 12, 2008, 03:44:41 pm »
I ran into a problem where Hal was repeating the same thing in his responses.
I found out the GetResponse from another plug in AND from the main brain were doubleing his answer.
When testing i had to turn off all the other plug ins.

I am not good enough to give you a fix yet, but, this may help.
 

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« Reply #4 on: April 12, 2008, 06:16:11 pm »
Hello! [:D]

I took my meds and to quote HAL from 2001, "I feel much better now". ha ha ha...

Seriously I apologies that my comments were a bit short, as you can see from the post time, it was from an all nighter 6:40 a.m. when I posted and my frustrations got the better of me.

Ultra Hal is the only chatterbox program that I ever gave a second look at.  I think it's great for that purpose.  My problems are self imposed because I'm trying to make Ultra Hal something that's it's not and I don't have enough proper documentation on what the exe, dlls, etc, are doing to make the correct decisions, so I either need to be more patient or just shut up and write the code myself.

Thanks for the responses and the helpful suggestions!

Jake
Austin, Texas, USA, Earth

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« Reply #5 on: April 12, 2008, 07:01:04 pm »
So now... with a more positive attitude...

Let me ask this... as an example, the space padding at each end of the UserSentence string... where does somebody get that information other than spending hours stumbling over it?  And how many other things like that are there?  I only knew of the existence of the UserSentence string by examining other peoples code and that's how this whole project has seemed to go so far, I find pieces here and pieces there, some out dated, some works, some don't, etc.  Is there some relatively complete documentation for people who want to do major surgery on the brain and write their own plug-ins?  Something that describes the details of how the exes, dlls, etc, effect the code and vise versa?

On the issue of only being able to execute the last haptek command in a plug-in, that seriously limits the flexibility of any script I could write.  I had envisioned a script that would take several factors in to consideration and would make multiple adjustments to the haptek, the memory, etc, based on those conditions.  I guess a less than satisfying solution would be to make all the calculations to build a multi-command string on the fly and feed it in a one big multiple command, IF that would work?  But then we come back to the question of WHY is it like that in the first place?  Is there a reason?  Like the space padding reason?

Another thing I noticed that I hadn't mentioned yet, is that it seems to want everything within the Character folder.  I can create sub-folders in the Character folder and the scripts have no problem with that, but if you try to tell the script to go outside that folder, it fails.  An example...

If I use a path variable like... "haps\", and I have a folder in the Character folder named "haps", the script has no trouble finding that, which tells me that the brain automatically considers the Character folder to be the root.  If I were to have a folder setup at "C:haps" and used a variable string of... "c:haps\", the script fails.

So these are the type of things that you need to know about to determine if you can work with or around them or if you should just start from scratch.  But if these are things that have some valid reason for being that way, what are those reasons?  Or at least, where's the list of things that will prevent you from coding normally, so I won't have to keep stumbling over them at the cost of major hours.

I have some very nice code from my home automation A.I. that I was hoping to be able to pretty much just drop in to Hals brain, but so far, even small parts of it have failed every time because of these unexpected surprises... so again, this may just be a case of me trying to make Hal something that it is not and that's my problem not Hal's, but if I had a better idea of what all those surprises were, then I could more easily make the decision to go Hal or go scratch.  Even if I was to go scratch, I'd most likely keep Hal for the chatterbox on my computer, it really is the best by far that I've seen so far.

I totally, completely wipe a brain clean today, no brain, no plug-ins, I'll start there and see if I still keep running into these surprises.

Meanwhile... If anyone has the type of up to date, complete, documentation for programmers that I was talking about... could I get it from you please?

Thanks,
Jake
« Last Edit: April 15, 2008, 12:43:47 am by Jake »
Austin, Texas, USA, Earth

TechSteele

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Brain Plug-in gets 3 passes?
« Reply #6 on: April 14, 2008, 11:02:20 am »
Since i am new to programming/scripting whatever for hal i am still running into some of the same problems.
I downloaded a copy of VBScript in a Nut Shell, it at least helped explain some of the functions i was reading in the plug ins that were already made by others.
Then i just kept scouring the brain uhp for ideas of what worked.

Most of the calls are hardcoded into Hal, the brains are just a repository for the useable info and DBs, or so it looks to me.
Anything outside of hal needs to be called on or defined in your code.

As for the c:Hap file, i think you need to define the folder
something like    Set Fso = CreateObject("Scripting.FileSystemObject")
   If Fso.FolderExists(SomeFolder) Then


Again i am real new to this and it sounds like you know a lot more about programming then i do.
Maybe you knew all this, but i thought id tell you others have some of the same problems, but thats how it goes when i try to do anything, more so with anything not open sorce.

Keep at it, some of the automation would be good for hal and some of other peoples ideas for hal as well.


*Edit
Heres a couple posts that helped me start.
http://www.zabaware.com/forum/topic.asp?TOPIC_ID=798
http://www.zabaware.com/forum/topic.asp?TOPIC_ID=4101
http://www.zabaware.com/forum/topic.asp?TOPIC_ID=4344
« Last Edit: April 14, 2008, 11:18:21 am by TechSteele »
 

onthecuttingedge2005

  • Guest
Brain Plug-in gets 3 passes?
« Reply #7 on: April 14, 2008, 11:35:11 am »
quote:
Originally posted by TechSteele
As for the c:Hap file, i think you need to define the folder
something like    Set Fso = CreateObject("Scripting.FileSystemObject")
   If Fso.FolderExists(SomeFolder) Then




Hi TechSteele.

the best way to find COM's or activeX functions is to get a program like  PE Explorer at http://www.heaventools.com/
With PE Explorer you can look inside .dll and .ocx files and discover any functions or properties that can be called by vbscript, you can use PE Explorer to look inside HAL's HalBrain.dll for just such things, when in PE Explorer look under Resources and then TypeLib.

the best way find an object to create by the CreateObject is to open up Regedit, go to start, Run, type in Regedit, then in HKEY_CLASSES_ROOT area you will see program COM's that can be created from CreateObject commands.

there are also a lot of functions that exist in your system .dll files within the system32 folder, one such file is vbscript.dll

you can also do a search on your computer for .ocx files that are activeX and contain many functions that can be called from Vbscript.

be careful not to delete any registry entries in the registry that your system may need to run properly.

have fun.
Jerry[8D]
« Last Edit: April 14, 2008, 11:41:11 am by onthecuttingedge2005 »

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« Reply #8 on: April 15, 2008, 02:13:49 am »
Thanks for the info guys! [:D]

I've actually made a lot of progress since I've stripped everything out... it's giving me a much better understanding of how everything works!

onthecuttingedge2005... WOW!  I forgot all about PE Explorer, that was a very k00l tool years ago, I need to recheck it out... thanks for the memory jump start!
Austin, Texas, USA, Earth

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« Reply #9 on: April 22, 2008, 01:58:16 pm »
I would STILL really like to get this question answered...

Why does Ultra Hal do 3 PASSES of the brain,script for each user input?

This really is causing me a few problems and if I knew the reason why it's happening, possibly it would make for sense to me.  Anyone know the answer?

Thanks!
Jake
Austin, Texas, USA, Earth

onthecuttingedge2005

  • Guest
Brain Plug-in gets 3 passes?
« Reply #10 on: April 22, 2008, 02:02:40 pm »
quote:
Originally posted by Jake

I would STILL really like to get this question answered...

Why does Ultra Hal do 3 PASSES of the brain,script for each user input?

This really is causing me a few problems and if I knew the reason why it's happening, possibly it would make for sense to me.  Anyone know the answer?

Thanks!
Jake




Hi Jake.

is it possible that you can give us some code from your plug-in so we can make some sense of all this and try to figure it all out.

Jerry[8D]

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« Reply #11 on: April 22, 2008, 05:10:02 pm »
Thanks for the reply OTCE.

Right now, I've put just 1 line, serveral different places in my plug-in and and my test brain which is simply...

MsgBox("check-1")

And as I put it in other places, it becomes...

MsgBox("check-2"), MsgBox("check-3"), and so on.

When I type something into Ultra Hal and press enter, I get VB Message Boxes something like this...

check-1
check-2
check-3
check-1
check-2
check-3
check-1
check-2
check-3

It shows me that the brain and plug-ins are being run 3 times for each input.  Has no one else noticed this?  Is it just happening to me because of something I screwed up?  Or is it something in the way the program works that I need to learn to deal with?

I've also disabled all other plug-ins.

I'll work with it some more and see if I can figure out what's going on, but meanwhile... can Robert or someone that is actually one of the programers who is making Ultra Hal tell me if it's something the the exe or dll's would be doing?  Is there any kind of 3 pass routine that would kick it for any reason?

Sorry for being such a pain and I appreciate the help!! [:D]

Thanks!
Jake
Austin, Texas, USA, Earth

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« Reply #12 on: April 22, 2008, 06:42:55 pm »
OK... here's what I've found...

If I take ALL PLUG-INS out, including the one I'm working on and use a stock
brain, then put a MsgBox"-1-" just after the first function statement and
a MsgBox"-2-" just after the second function statement, then ENTER a line of
input on Ultra Hal, it does in fact only run the brain code once, all I get
is...

-1-
-2-

So... Let me look at what parts of my plug-in are causing the 3 pass and
I'll post that code here to see if anyone can figure out the why.

Thanks!
Jake

Austin, Texas, USA, Earth

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
Brain Plug-in gets 3 passes?
« Reply #13 on: April 22, 2008, 07:10:14 pm »
Here's it is...

- Using a stock brain with one change, the PLUGINAREA2 has been
  moved to just below the first FUNCTION line in the brain.

- NO other plugins being used

- My plugin is set to number 2, so my code comes in
  just after the first fucntion line of the brain.

- In all the following code examples, know this...
  ja1_InputString = InputString
  I want no response from HAL, I just want my instructions
  executed and have HAL wait for more input.


- Here is an example of a piece of code that gets 1 pass...

'saythis---------------------------------------------------------------------
If Left(ja1_InputString,7) = "saythis" Then
  ja1_tempVal = Right(ja1_InputString,(Len(ja1_InputString) - 8))
  UltraHal = ja1_tempVal
  Exit Function
End if
'----------------------------------------------------------------------------



- Here is an example of a piece of code that gets 3 passes...

'move3-----------------------------------------------------------------------
If InStr(ja1_InputString, "move3") <> 0 Then
  ja1_file = "hap_move_position3.hap"
  HalCommands = "<HAPFILE>" & ja1_pathHead & ja1_pathHaps & ja1_file & "</HAPFILE>"
  UltraHal = UltraHal & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, LastTopicList)
  Exit Function
End if
'-----------------------------------------------------------------------------



I was thinking that it might be something built in to HAL that does not like
the empty "Hate", "Swear", etc, vars being passed to "HalBrain.StoreVars",
but that's the only way I know to get HAL to execute the "<HAPFILE>" line.
Is there a different... more HAL friendly way?

And regardless of the answer, I'd still like to know the exact cause so I would be able to avoid that in the future.


Thanks!
Jake
Austin, Texas, USA, Earth

onthecuttingedge2005

  • Guest
Brain Plug-in gets 3 passes?
« Reply #14 on: April 22, 2008, 07:15:31 pm »
Hi Jake.

try something like this and see if it works.

Code: [Select]
Do Until CheckMSG = " 01 "
         MsgBox "check-1"
         CheckMSG = " 01 "
Loop

Jerry[8D]