Wednesday, May 28, 2008

Program E Bug Fix

This is the fix we found for the bug we reported in Program E.

I am working with a developer who knows PHP well but not too much AIML. I know AIML but not much PHP. He found something in the code that apparently fixes the bug, at least in the tests we have done. I don't know if anyone is officially maintaining Program E at the moment, but anyone working with the code may be able to check this solution.

By the way, we are using version 0.8 of Program E.

Here is what he said:

Dr. Wallace, this is piece of code which was changed by me. The only line I added is highlighted below.

This code is executed when no match is found by the “graphwalker”.

As graphwalker searches for matches it adds words matched by the “*” wildcard to $inputstarvals.

But when it reaches it the end of the input and finds no matches it should clear $inputstarvals reference and return back to the root of the tree.

// Else no match found...

if ((($whichresult[0]==-1)&&($whichresult[1]==-1)&&($whichresult[2]==-1))||($continuenode==1)) {

//If we were most recently on a wildcard (*,_) then we are still matching it.

if (($onwild==1)&&($word!="")&&($word!="")&&($word!="")){

debugger("On wild and in *. keep going with graphwalker.",2);


return graphwalker($remains,$parent,1,1,$parton,$inputstarvals,$thatstarvals,$topicstarvals,$patternmatched);


else {
//We didn't find anything. We need to come back out


debugger("Result is blank from query in *. Returning blank",2);

return "";



Attached is the latest (Program E 0.9) version of this script. We use version is 0.8. This code should work the same way in the latest version. Changes which were introduced between 0.8 and 0.9 are not related to this piece of code.


  1. Is there something else that could be going on here? (or a difference somewhere else between v0.8 and v0.9?) I am using Program E, v0.9 and do not seem to have this bug. I did the "TEST ME" test as described in the previous post and do not seem to have this problem. I have the pattern "TEST ME" returning "I am testing you!" and the other patterns: "_ TEST ME *" AND "TEST * ME" all currently work - without the fix. ???

  2. PS - my bot is up for chatting at:

  3. What this fix does, it extends the graphwalker to the "that" and "topic" tags as well.

    Just a short note;
    This line:
    if (($onwild==1)&&($word!="")&&($word!="")&&($word!="")){
    could safely be just:
    if (($onwild==1)&&($word!="")){

    You don't need the ($word!="") condition three times in a row...

    PS: this blog doesn't allow aiml tags in comments, so we cannot post corrected codes or such...

  4. Curious if programE ever be updated at sourceforge?



blogger templates | Make Money Online