Thread: RoDBoT: BETA

  1. #16
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Originally posted by RoD
    i'm stuck guys. if i enter more than one keyword she responds and dumps.
    Use getline(). I remember you arguing how getline() is better than cin
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  2. #17
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i cant.

    Code:
    cout << "Enter Comment: ";
    getline(cin,userInput);
    gives me

    Code:
    -------------------Configuration: RoDBoT - Win32 Debug--------------------
    Compiling...
    RoDBoT.cpp
    C:\Program Files\Microsoft Visual Studio\MyProjects\RoDBoT\RoDBoT.cpp(234) : error C2780: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &,const _E)' : expects 3 argument
    s - 2 provided
            c:\program files\microsoft visual studio\vc98\include\string(149) : see declaration of 'getline'
    C:\Program Files\Microsoft Visual Studio\MyProjects\RoDBoT\RoDBoT.cpp(234) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &)' : could not deduce template a
    rgument for 'class std::basic_string<_E,_Tr,_A> &' from 'char [256]'
    Error executing cl.exe.
    
    RoDBoT.obj - 2 error(s), 0 warning(s)

    but elsewhere in my program

    Code:
    cout << "Please enter your name: ";
    	getline(cin,name);
    works fine....been a long day in bot hell.

  3. #18
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    oops, wasn't being descriptive enough, try this

    Code:
    cin.getline(userInput, 256, '\n');
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  4. #19
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    nope that way it prompts and immeadiatly ends...

    new discovery, consider this code:

    Code:
    void Conversation::prompt()
    {
    
    	cout << "Enter Comment: ";
    	cin >> userInput;
    
    	/*	Convert entire character array 
    		to lowercase. Thanks to Travis Dane for
    		the for..loop idea.
    	*/
    	for (int i = 0; i < strlen(userInput); i++)
    	{
    		userInput[i] = tolower(userInput[i]);
    	}
    
    	convo();
    }
    
    /*	Function:	covo
    	Purpose:	This is where all the magic happens!
    */
    void Conversation::convo()
    {
    	/*	Big thanks to eibro for getting
    		me going with this section,
    		without his help rodbot would ve
    		a total dumbass.
    	*/
    	ifstream compareFile("comp.txt");
    	ifstream lookupFile("ans.txt");
    
    	if (compareFile.fail()) 
    	{
    		cout << "Fatal Error: Missing comp.txt and/or ans.txt!\n";
    	}
    	else if (lookupFile.fail())
    	{
    		cout << "Fatal Error: Missing comp.txt and/or ans.txt!\n";
    	}
    
    
    	string place_hold;
    	int indexNum;
    
    	
    
    	while (getline(compareFile, place_hold))
        {
    		
            stringstream format;
            format << place_hold;
            format >> indexNum >> place_hold;
           
            if (userInput == place_hold)
            {
    			
                int compareNum;
                string compareString;
                while (getline(lookupFile, compareString))
                {
                    stringstream convert;
                    convert << compareString;
                    convert >> compareNum;
    				
                    getline(convert, compareString);
                    if (compareNum == indexNum)
                    {
                        cout << compareString << endl;
    					prompt();
    				}
    
    				/*
    				else  
    				{
    					cout<<"bhb\n";
    					prompt();
    				}
    				*/
    	
    						
                    
    				
                }
    			
            }
    	 
    		
    	
        }
    
    	
    }

    now like that anytime u enter a keyword it works....now modify the lower if to this:

    Code:
    if (compareNum == indexNum)
                    {
                        cout << compareString << endl;
    					prompt();
    				}
    				else  
    				{
    					cout<<"bhb\n";
    					prompt();
    				}
    now it only works if u enter the keyword hi, the first keyword in comp.txt, so why is the else making it stop looking after line 1?

  5. #20
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    heres the cpp...

  6. #21
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by RoD
    getting the error handling is giving me errors im having trouble handling :P
    Then you should install error handlers that handle errors in
    error handlers...

  7. #22
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    ok i'm getting somewhere, the else is throwing it off becuz it loops until they are ==, and if on pass one they arent it hits the else....

  8. #23
    Registered User
    Join Date
    Nov 2002
    Posts
    36

    How about...???

    How about introducing yourself first.. like a nice and polite robot...
    and asking the user/stranger their info like you r doing a real conversation instead of being a regular commanding computer..
    eneter your name... bla.. bla.... if you have intention to make it a sex toy... then its different case.... :O
    will be there one day!

    I usually use VStudio 6!

  9. #24
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Hmmm, I don't think the algorithm I gave you is going to work.
    Okay, I should have did this the first time around... but here goes.

    [list=1][*]Get user input[*]Open conversation file and search for the word(s?) entered by the user.[*]Record the index number if an entry was found, else, print a default message (eg. "Take off your pants") and goto step 1[*]Open up answers file and search for the desired index number, if it's found, print the cooresponding string, else print a default message.[*]Goto step 1[/list=1]

    The only thing I see as a problem is step 2... the user isn't going to enter a single word response so we're going to need to search for each word in the conversation file. For each response found, push the index number onto a vector. If a response isn't found, push a predetermined value onto your vector (like 0). Finally, iterate through the vector and find the index number which occoured the most frequent. Search for a response in the answers file with this index. Print, and go to step 1.

    I'll help you out with this tommorow. I suggest breaking it up into classes/objects (answer, response, index, bot, etc.)

  10. #25
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    ok thnx eibro, i wiped out the convo function last night.

    >>How about introducing yourself first.. like a nice and polite robot...
    and asking the user/stranger their info like you r doing a real conversation instead of being a regular commanding computer..


    what are u talkin bout??? so i guess it doesnt count when he takes in name/age/sex then tells his name/age/sex?? did u use it at all??

  11. #26
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by RoD
    what are u talkin bout??? so i guess it doesnt count when he takes in name/age/sex then tells his name/age/sex?? did u use it at all??
    So tell me, When you first meet a person you ask
    "Name? Age? Sex?" ?

  12. #27
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    >>So tell me, When you first meet a person you ask
    "Name? Age? Sex?" ?


    nowadays asking the sex may be a good idea...

  13. #28
    Registered User
    Join Date
    Nov 2002
    Posts
    36

    Okay...

    >>nowadays asking the sex may be a good idea...
    So, do you introuduce yourself first or ask somebody to introduce him/herself first...???
    >> Enter you name:... Enter your.. bla bla...
    or..
    Hey what's up?? My name is Rod.. I'm bla bla... And what's you's
    which sounds better and more normal...???
    :):)

  14. #29
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i'll add to the list.

  15. #30
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Code:
    	while(userInput != "goodbye")
    	{
    	
    		while (getline(check, temp))
    		{
            stringstream format;
            format << temp;
            format >> index >> temp;
           
            if (userInput == temp)
            {
                
                while (getline(answr, comparestring))
                {
                    stringstream convert;
                    convert << comparestring;
                    convert >> comparenum;
    
    
    					getline(convert, comparestring);
    
    				
    					if (comparenum == index)
    					{
    						cout << comparestring << endl;
    						user();
                     
    					}
    				
                }
            }
    		
    		
        }	
    	
    	}
    if i can find a way to stop the loop, set a false/true, then exit to an if to check state i'll be ok. I had tried getting length of the file and running it till it was eof, then setting state, but to no avail. Does anyone have a suggestion?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beta version compiled with -DWINVER=0x0500
    By wow in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2006, 06:35 AM
  2. MS Visual Studio .NET 2005 beta 1
    By Vader in forum C++ Programming
    Replies: 8
    Last Post: 09-21-2004, 07:14 PM
  3. Natrual Language Programming - Beta Release
    By andy668 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-16-2002, 12:24 AM
  4. Visual Studio .NET beta 2
    By Marky_Mark in forum C++ Programming
    Replies: 1
    Last Post: 11-05-2001, 10:28 AM