Click to See Complete Forum and Search --> : Ramdom Phrase Generator.
Bazoukas90
07-04-2001, 09:33 PM
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
pyromidion
07-04-2001, 11:19 PM
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
Bazoukas90
07-04-2001, 11:48 PM
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
Bazoukas90
07-05-2001, 12:12 AM
Never mind http://www.sharkyforums.com/ubb/biggrin.gif
I did a real off the wall thing with a switch case method and to my suprise IT WORKED http://www.sharkyforums.com/ubb/biggrin.gif
------------------
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
Vacindak
07-08-2001, 03:52 PM
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.
driver
07-12-2001, 03:29 AM
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. http://www.sharkyforums.com/ubb/smile.gif
------------------
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
OmegalordX
07-15-2001, 11:12 PM
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?