Like Tree1Likes
  • 1 Post By manasij7479

Simple A.I. chat bot?

This is a discussion on Simple A.I. chat bot? within the C Programming forums, part of the General Programming Boards category; Trying to develop a very simple A.I. chat bot. You know, like one of those old school chat bots that ...

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    9

    Simple A.I. chat bot?

    Trying to develop a very simple A.I. chat bot. You know, like one of those old school chat bots that you could type responses, and the bot would spit out text... but I'm having a hard time.

    I have lots of questions, but I'll try to just ask a few 'main' ones first.

    1. How do you accept user input that is more than one character long? I've been using getchar() for everything, but it'd be nice if I could have the user actually type a few words, and it all fit into one variable that I could then dissect.

    2. How do I make the program to constantly wait for input? Meaning, the user opens the program, it says something, waits for input. Upon pressing enter, the program says something based on the input, then waits for input again... and again, and again. I keep getting either infinite loops or errors.

    That's pretty much it for now, if I could just get the program to do the above, I'd be a lot farther off than I am. Thanks for any and all help.
    Last edited by failCprogrammer; 09-10-2011 at 08:48 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1. Cprogramming.com FAQ > Get a line of text from the user/keyboard (C)
    2. Input is line buffered typically, so you don't have to do anything for that.
    edit - I misread your second point, Tater covered it though.


    Quzah.
    Last edited by quzah; 09-10-2011 at 08:58 PM.
    Hope is the first step on the road to disappointment.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    1. Look up fgets() in your C library documentation.
    2) Read your C textbooks ... section on loops.

    What you probably need to do before you undertake a relatively amitious project is to sit down with a good C Programming book . Start on page 1, read, type up the examples, do the exercises, play with the code until you understand it, review as necessary... turn to page 2, repeat until you get to the end of the book.

    Programming languages are not something you learn piece meal... climb in and make a deliberate study or at some point realize you've bitten off more than you can chew.

  4. #4
    Registered User
    Join Date
    Sep 2011
    Posts
    9
    Thank you Tater. Yes, you're right. Because I've dabbled in a few different programming languages, I feel that I can program... when in reality I guess I can't... or to the extent that I wish I could. I have so many great ideas for great programs, but I have to acknowledge that my programming level isn't as high as my aspirations. I will do what you suggest...although it will suck, lol.

    I have C for Dummies and The C Programming Language. C for Dummies is great, simple, and easy to read, but it definitely skips out on a bunch of what I feel is important to C. It doesn't even mention fgets() or goto(), for example. The C Programming language is a lot better, but assumes you know C already. Can you suggest any books that are good on C? And how much of C would I really need to know before I could create a very good AI chat bot? What I mean is, what would an AI chat bot consist of? Wouldn't it just be methods, and a bazillion if else statements?

  5. #5
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Quote Originally Posted by failCprogrammer View Post
    And how much of C would I really need to know before I could create a very good AI chat bot? What I mean is, what would an AI chat bot consist of? Wouldn't it just be methods, and a bazillion if else statements?
    Simple answers:
    1. more than you know now.
    2. no.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by failCprogrammer View Post
    Thank you Tater. Yes, you're right. Because I've dabbled in a few different programming languages, I feel that I can program... when in reality I guess I can't... or to the extent that I wish I could.
    Trust me... if you know bits and pieces of 6 or 7 programming lanuages, you don't know any language.


    I have so many great ideas for great programs, but I have to acknowledge that my programming level isn't as high as my aspirations. I will do what you suggest...although it will suck, lol.
    Y'know what... work isn't about working ... it's about doing something that gets you something else... You go to work each day so you get a paycheque at the end of the week... that in turn gets you a home, food, clothing... the little things.

    Studying is merely a form of work where the payoff is in terms of knowledge, instead of dollars.

    I have C for Dummies and The C Programming Language. C for Dummies is great, simple, and easy to read, but it definitely skips out on a bunch of what I feel is important to C. It doesn't even mention fgets() or goto(), for example. The C Programming language is a lot better, but assumes you know C already. Can you suggest any books that are good on C?
    Ok so, do C for Dummies first then hit K&R ... You already have them, so no new expenses incurred.


    And how much of C would I really need to know before I could create a very good AI chat bot? What I mean is, what would an AI chat bot consist of? Wouldn't it just be methods, and a bazillion if else statements?
    (Ignoring for the moment that you are trying to write one of the singly most annoying pieces of software ever created)

    How much C do you need to know... All of it. No joke... There's an engineer I used to know who became well known for his incomplete projects and barely adequate results... they dubbed him the "King of Halfassed" and last I heard of him he was driving Taxi. If you're going to do something at least have the common sense to do it right.

    For the Bot itself ... it's a lot more than a couple of subroutines (C does not have "methods") and conditional statements... you are talking about software that is at least intelligent enough to *appear* to respond to a user's input... That means it has to in some way understand human language and be able to select --perhaps even compose-- it's response from that. That means grammatical analysis at least able to determine the tense, subject and any modifiers of a sentence or paragraph and a search algorythm capable or selecting an appropriate response based on the analysis... Definately NOT "Coding for Dummies".

  7. #7
    Registered User
    Join Date
    Sep 2011
    Posts
    9
    Lol alright geeze geeze I get it. Gonna hit the books then, and come back when I know C entirely. Thanks though for being honest.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by failCprogrammer View Post
    Lol alright geeze geeze I get it. Gonna hit the books then, and come back when I know C entirely. Thanks though for being honest.
    ah calls 'em as ah sees 'em.

    You're welcome.

  9. #9
    Registered User
    Join Date
    Sep 2011
    Location
    India
    Posts
    27
    I believe what u r trying to do is support multiple chat users from remote end chatting with ur chat bot.

    The correct method to implement this to use Multi-threading.

    - As soon as one user comes start a new thread and let that thread handle that user.
    - i.e. One thread per user.

    - The advantage of this will be that you will program one thread per user and initiate the same thread for all users, and thus all your infinite loop problems etc will be gone.

    Code:
     
    I think you need to implement multi-threading kind of a thing

    Quote Originally Posted by failCprogrammer View Post
    Trying to develop a very simple A.I. chat bot. You know, like one of those old school chat bots that you could type responses, and the bot would spit out text... but I'm having a hard time.

    I have lots of questions, but I'll try to just ask a few 'main' ones first.

    1. How do you accept user input that is more than one character long? I've been using getchar() for everything, but it'd be nice if I could have the user actually type a few words, and it all fit into one variable that I could then dissect.

    2. How do I make the program to constantly wait for input? Meaning, the user opens the program, it says something, waits for input. Upon pressing enter, the program says something based on the input, then waits for input again... and again, and again. I keep getting either infinite loops or errors.

    That's pretty much it for now, if I could just get the program to do the above, I'd be a lot farther off than I am. Thanks for any and all help.

  10. #10
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,490
    Quote Originally Posted by sumit180288
    The correct method to implement this to use Multi-threading.
    The correct way to test a weapon is to wage a war.
    Last edited by manasij7479; 09-12-2011 at 05:31 AM.
    AndrewHunter likes this.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by sumit180288 View Post
    I believe what u r trying to do is support multiple chat users from remote end chatting with ur chat bot.
    Where did he say that?

    Meaning, the user opens the program, ...
    Says nothing about multiple users or remote users... Those are YOUR assumptions and they are bound to be plenty confusing to a beginning programmer.

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by manasij7479 View Post
    The correct way to test a weapon is to wage a war.
    I don't know if waiting until you are committed to a war is the best time to start testing your arsenal. <half hearted attempt to tie in the Pig War just because it's silly>


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple chat program questions
    By surefire in forum C Programming
    Replies: 5
    Last Post: 11-05-2009, 07:16 PM
  2. Simple Socialising Chat Bots
    By bengreenwood in forum C++ Programming
    Replies: 10
    Last Post: 11-28-2007, 07:42 AM
  3. simple chat program
    By daioyayubi in forum Windows Programming
    Replies: 8
    Last Post: 12-07-2005, 11:12 AM
  4. simple chat program
    By ender in forum C++ Programming
    Replies: 1
    Last Post: 11-12-2001, 10:48 PM
  5. Simple Chat program. Help.
    By knave in forum C++ Programming
    Replies: 0
    Last Post: 09-16-2001, 02:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21