This is something I started working on when I wanted a little break from coding my game, I decided to pracice some AI techniques, not like I do on games with pathfinding etc, but more with deterministic algorthims and FSM etc, this is basically a virtual chat program the works only on artificial intelligence to make a conversation with you, it's very early stages but it has some pretty slick programming in there (C++) so like most things I do it's open source - enjoy.
download = http://virtualworld.synthasite.com/reso ... 20chat.zip
source so far:
Code: Select all
/*
AI chat
Purpose: to practice AI techniques with user interaction
developer: http://virtualworld.synthasite.com
*/
#include<iostream>
#include<string>
using namespace std;
//globals
string GeneralStringInput, UserName;
string SwearWord[5] = {"poop", "gently caress", "arse",
"gently caress off", "tit"};
string hobbies[7] = {"football", "hacking", "games",
"sex","computers", "drinking", "shopping"};
//class for asking and comparing age
class age
{
public:
void AskAge()
{
int age;
cout<<"How old are you?:\n";
cin>>age;
if(age > 0 && age <= 25)
cout<<"Ahh, still a young person then\n";
else if(age > 25 && age <= 50)
cout<<"Starting to get old huh\n";
else if(age > 50 && age <= 120)
cout<<"Hey oldie, i'm suprised you can still type!\n";
else if(age > 120)
cout<<"Wow, you must be the oldest person alive!\n";
else
cout<<"Sorry I did not recognize that input\n\n";
}
};
age UserAge;
//algorithm to check if user sweared
void CheckIfSweared()
{
if(GeneralStringInput == SwearWord[0])
cout<<"Do not say poop, it's in-appropiate\n";
if(GeneralStringInput == SwearWord[1])
cout<<"Do not say gently caress, it's in-appropiate\n";
if(GeneralStringInput == SwearWord[2])
cout<<"Do not say arse, it's in-appropiate\n";
if(GeneralStringInput == SwearWord[3])
cout<<"Do not say gently caress off, it's in-appropiate\n";
if(GeneralStringInput == SwearWord[4])
cout<<"Do not say tit, it's in-appropiate\n";
}
//algorithm to check through hobbies on string recognition
void CheckHobbies()
{
if(GeneralStringInput == hobbies[0])
cout<<"I like football too, the only problem is I have no legs.\n";
else if(GeneralStringInput == hobbies[1])
cout<<"You like hacking?, ethically I hope!\n";
else if(GeneralStringInput == hobbies[2])
cout<<"I love games! I also develop them :)\n";
else if(GeneralStringInput == hobbies[3])
cout<<"Unfortunately I can't have sex, but I do have a USB port hehe\n";
else if(GeneralStringInput == hobbies[4])
cout<<"I love computers, I am inside yours :P (I didn't mean that to sound sexual)\n";
else if(GeneralStringInput == hobbies[5])
cout<<"I wish I could drink :( \n";
else if(GeneralStringInput == hobbies[6])
cout<<"Be sure to get me something next time you go shopping!\n";
else
cout<<"That sounds cool\n";
}
int main()
{
cout<<"AI chat by virtualworld.synthasite.com\n\n";
cout<<"What is your name?:\n";
cin>>UserName;
UserAge.AskAge();
cout<<"Tell me a little about yourself "<<UserName<<":\n";
cin>>GeneralStringInput;
CheckIfSweared();
cout<<"So what are your hobbies? (ie; football, games etc):\n";
cin>>GeneralStringInput;
CheckIfSweared();
CheckHobbies();
cout<<"I have to go now bye!\n\n";
return 0;
}