Hm, interesting. I did a similar project to yours in middle school for my own amusement, using the same method as well. In my junior year, in the tail end of 2016
I made a new scheme for a similar idea, and a year later
I made a game with this same engine. I'll see if I can show you what I did to improve my system through the years.
What I ended up doing for processing string input is taking each space-delimited word and looking it up in a little "table" of sorts (which also has synonyms and some misspellings), and checking for a certain list of words in order to give a response. This allows much flexibility in what one can enter.
For example, "WHAT ARE YOU CALLED" might be transformed into "398C" after the words are looked up, as would "WAT R YA CALLED" or "WUTZ R U CALLD". Checking to see if it was transformed into "398C" checks for those and more with one command.
Keep in mind, this was my own method, and perhaps this would be either too hard or too overkill for your purposes. A simpler way to allow a bit more flexibility with input is to do the following:
" "+Str1+" "->Str1
If inString (Str1," HI "):Then
Disp "HEY, NERD."
End
assuming Str1 contains your input. This would allow the same response for "HI", "HI THERE", "OH HI ERMINE", and much more, but not "I LIKE THIS" (a string that simply has H and I in that order).
As far as producing different outputs, you might want to look into randomized output. Come up with a bunch of different responses, and then do this:
If inString(Str1," HI "):Then
randInt(1,5->R
If R=1:Disp "HEY, NERD."
If R=2:Disp "OH, HI."
If R=3:Disp "YO, DUDE."
If R=4:Disp "WHAT IS IT THIS","TIME?"
If R=5:Disp "HEY, DIDN'T SEE","YOU THERE."
End
This code has a 1/5 chance of returning "HEY, NERD.", "OH, HI.", "YO, DUDE.", etc. There are quite a few ways of optimizing this, but for now I'll leave this as an exercise to the reader
![Wink ;)](Smileys/cwsmileys/wink.gif)
One last thing to consider: you cannot possibly code for every possible input individually, but the chatbot should respond to anything inputted to it. To handle this, perhaps code in some catch-all messages for when no pattern was matched. Here's the way I'd do that:
If inString(Str1," HI "):Then
"HI code here
Goto E
End
Repeat 1
"catch-all code here
Disp "SORRY, I DON'T","UNDERSTAND."
Lbl E
End
This jumps past any other command checking so it doesn't respond twice, and it allows for the chatbot to respond to literally anything, even if it doesn't understand it.
I hope this helps you improve ERMINE!