AI chat bot in cpp

Programming, for all ages and all languages.
Post Reply
nuno_silva_pt

AI chat bot in cpp

Post by nuno_silva_pt »

does anyone knows of any link on tutorials on how to create a AI chatbot in c++? Thanks 4 ur help ppl!
mystran

Re:AI chat bot in cpp

Post by mystran »

Depends probably on what you mean by "AI chat bot"?

Something like Eliza is covered in nearly any AI book, at least in any Lisp ones. The same principles apply in C++, and learning enough Lisp to understand those is really not hard.

I would imagine any C++/Java AI book to include something similar though, but haven't read any such book, so can't say for sure. Anyway, the basic idea is:

1. Read a sentence from user.
2. Match the sentence to a set of "template rules", possibly capturing some parts of the user sentence. To do this you want to first split the sentence into words.
3. Based on the matching template, construct a response, possibly by taking a random one of a set of possible responses.

To make it more sophisticated, you can add some memory, some way to notice synonyms and general categories, ability to backtrack into an earlier subject if you can't find a good response, and other similar stuff.

For an IRC bot you also want some initial trigger like the nick name so the bot won't respond to everything, and a small random delay before responses so it appears more human.

That should get you started. Once you've done this and played with it for a minute, you probably start thinking of other stuff to do. Trying to extract some statements into memory either by random or with some heuristics from other people's conversations can also do wonders..
Post Reply