Ramdom Phrase Generator.

Sharky Forums


Results 1 to 7 of 7

Thread: Ramdom Phrase Generator.

  1. #1
    Expensive Sushi
    Join Date
    Jun 2001
    Location
    IL
    Posts
    39

    Question Ramdom Phrase Generator.

    I made this program that asks you to calculate the product of random numbers. So far so good. But how can I make the program to generate apropriate random phrases for the correct and incorect answers?
    I made two switch cases. One that inlcudes the phrases for the correct answer and one for the wrong answers. But i dont know how to make them work.
    Thank you mucho.

    ------------------
    800p3 OCed to 850
    Gforce 256-32 DDR RAM
    256-100MhZ RAM
    DUAl 10.000RPM 60 Gig total, HDrives
    OSs: WIN2k-WIN98sec ed-LINUX MANDRAKE v8
    Soundcard realy sucks "Philips".
    ATA-TV reciever PCI Card
    HP 9100 CD burner
    DVD
    CD-ROM
    Cable modem.
    17 inc NEC-C700 monitor
    800p3 OCed to 850
    Gforce 256-32 DDR RAM
    256-100MhZ RAM
    DUAl 10.000RPM 60 Gig total, HDrives
    OSs: WIN2k-WIN98sec ed-LINUX MANDRAKE v8
    Soundcard realy sucks "Philips".
    ATA-TV reciever PCI Card
    HP 9100 CD burner
    DVD
    CD-ROM
    Cable modem.
    17 inc NEC-C700 monitor

  2. #2
    Goldfish
    Join Date
    May 2001
    Location
    San Jose, CA
    Posts
    87

    Post

    ok, if x = 1 number, and y = 2nd number and the answer = x*y then figure out what it is.
    lets say 5 * 6, so the answer is 30. check the input in an IF..THEN

    if inputtedAnswer = CorrectAnswer then
    write correct
    else
    write incorrect
    end if

    ------------------
    1.2Ghz Athlon T-bird
    SY-K7VTA Pro Mobo
    256mb pc/133
    8x DVD / 40x CD-ROM
    6x4x32x CD-RW
    ATI Rage Fury Maxx 64mb
    2gb HDD
    Asus A7n8x motherboard
    Athlon XP 2600+ 333fsb
    512mb PC 2700
    Maxtor 60gb (2x)
    GeForce4 Ti4200 128mb(Asus v9280td)
    52x24x52x16 Combo Drive

  3. #3
    Expensive Sushi
    Join Date
    Jun 2001
    Location
    IL
    Posts
    39

    Post

    I did that and so far the program works fine. It outputs one phrase for each correct answer and one phrase for each wrong answer. But I would like to make it so it will generate random responces. Ex. To have the program choose between 3 comments for a correct answer and 3 different comments for a wrong answer. Thats where I am stuck now.

    ------------------
    800p3 OCed to 850
    Gforce 256-32 DDR RAM
    256-100MhZ RAM
    DUAl 10.000RPM 60 Gig total, HDrives
    OSs: WIN2k-WIN98sec ed-LINUX MANDRAKE v8
    Soundcard realy sucks "Philips".
    ATA-TV reciever PCI Card
    HP 9100 CD burner
    DVD
    CD-ROM
    Cable modem.
    17 inc NEC-C700 monitor
    800p3 OCed to 850
    Gforce 256-32 DDR RAM
    256-100MhZ RAM
    DUAl 10.000RPM 60 Gig total, HDrives
    OSs: WIN2k-WIN98sec ed-LINUX MANDRAKE v8
    Soundcard realy sucks "Philips".
    ATA-TV reciever PCI Card
    HP 9100 CD burner
    DVD
    CD-ROM
    Cable modem.
    17 inc NEC-C700 monitor

  4. #4
    Expensive Sushi
    Join Date
    Jun 2001
    Location
    IL
    Posts
    39

    Post

    Never mind
    I did a real off the wall thing with a switch case method and to my suprise IT WORKED

    ------------------
    800p3 OCed to 850
    Gforce 256-32 DDR RAM
    256-100MhZ RAM
    DUAl 10.000RPM 60 Gig total, HDrives
    OSs: WIN2k-WIN98sec ed-LINUX MANDRAKE v8
    Soundcard realy sucks "Philips".
    ATA-TV reciever PCI Card
    HP 9100 CD burner
    DVD
    CD-ROM
    Cable modem.
    17 inc NEC-C700 monitor
    800p3 OCed to 850
    Gforce 256-32 DDR RAM
    256-100MhZ RAM
    DUAl 10.000RPM 60 Gig total, HDrives
    OSs: WIN2k-WIN98sec ed-LINUX MANDRAKE v8
    Soundcard realy sucks "Philips".
    ATA-TV reciever PCI Card
    HP 9100 CD burner
    DVD
    CD-ROM
    Cable modem.
    17 inc NEC-C700 monitor

  5. #5
    Expensive Sushi
    Join Date
    Jul 2001
    Location
    Webster, NY, USA
    Posts
    8

    Post

    Hehe, I know you already solved your problem but just in case you decide that you feel like getting really complex, you could do this:

    Set up a random phrase file format with various responses set up in a format something like this:

    {"Congratulations!","Good for you!","Wow!","Amazing!","Excellent work!"}"You"{"got it"{"right!","correct!"},"answered the"{"problem","question"}"correctly."}

    And something similar for a wrong answer.

    Then, parse through the file and generate a random response from the different synonymous elements that can be fit together to make a valid English phrase.

    I tried this once and it worked pretty well, though it took a long time to program and gave me plenty of headaches. With a large enough set of nested possible responses, the results can be quite random.

  6. #6
    Catfish
    Join Date
    Jun 2001
    Posts
    130

    Post

    actually, if you store your responses in an array of strings, then you can use a random number generator to generate a number within the range of this array and it would randomly pick one. This might be easier and more random than a switch network.

    ------------------
    AMD 1.2GHz Athlon 266FSB
    GlobalWin CAK38
    Asus A7M266
    Kingston PC2100 256MB
    IBM 75GXP ATA100 7200RPM 45GB
    Creative 12x DVD
    Yamaha 4x4x16x CD-RW
    Matrox G400 Millenium
    Matrox Rainbow Runner TV-Tuner/Capture Card
    SB Live! 5.1 Platinum
    Creative Dxr3 Decoder Card
    3Com 3C905B 10/100 NIC
    Mitsubishi 900u
    Antec PP403X 400W PSU
    In-Win A500
    AMD 1.2GHz Athlon 266FSB w/GlobalWin CAK38
    Asus A7M266
    Kingston PC2100 2x 256MB
    IBM 75GXP ATA100 7200RPM 45GB
    Creative 12x DVD
    Yamaha 4x4x16x CD-RW
    Matrox G400 Millenium
    Matrox Rainbow Runner TV-Tuner/Capture Card
    SB Live! 5.1 Platinum
    Creative Dxr3 Decoder Card
    3Com 3C905B 10/100 NIC
    Mitsubishi 900u
    Antec PP403X 400W PSU
    In-Win Q500

  7. #7
    Expensive Sushi
    Join Date
    Apr 2001
    Posts
    33

    Post

    Ok you got it to work but for kicks here is how i would do it:

    Store in file (as mentioned above by vacindak)

    {"Congratulations!","Good for you!","Wow!","Amazing!","Excellent work!"}"You"{"got it"{"right!","correct!"},"answered the"{"problem","question"}"correctly."}

    And use a random number generator (lets say you have 10 responses)

    int select_phrase=0;
    select_phrase=rand()%10; //generates between 0 and ten
    fopen(filename);
    for(i=0;i<select_phrase;i++)
    {
    scanf("file", stringname) //scan as string
    }


    When you are out of this loop you should have the random response. The syntax isnt all correct but you get the point.

    Would that work?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •