does anybody know how to make a programme say random things, things you tell it to say.
does anybody know how to make a programme say random things, things you tell it to say.
You can't make it say truly random things. You can write a program that has a set of possible things to say and have it randomly pick one.
I'm going to take this very literally for now. The FAQ has info about random. And you can play sounds using either a sound library, or via using an OS specific call. You can make list of sound files then use random to randomly play one of these sounds.
Now I'm going to take a stab at guessing what you were asking. If you mean make the computer respond verbally in an intellegent way, yes, but judging by your poor ability to formulate a simple question I think neural programming may be a wee bit over your head.
sorry, I mean where you type an array of things to say or something, and the computer says one at random
Just write the program yourself. Things you'd have to accomplish:
- keeping track of what things the computer might say.
- selecting one of those things at random.
- outputting the selection.
See if you can write in English (or whatever language) exactly what you want it to do. Give it as much detail as possible. This is the design phase of your program. Don't worry too much about how you'd do it in code, worry about how you would go about accomplishing that task in general. If you get stuck, then ask a question.
Oh well then do as my first suggestion says. Have a library of sound files somewhere and do something simple like this:
Example
Do note that my sample is more pseudo code than anything.Code:void PlayRandomSoundClip(void) { const char *filenames[] = {"hello.wav", "good.wav", "whale call.wav"}; PlaySound(filenames[rand()%3]); }
>does anybody know how to make a programme say random things
Code:#include "iostream" #include <malloc.h> void main() { char *s = (char *)malloc(0); int i; gets(s); s[i] = s[i++] + s[i++]; printf("%p -- %s -- %d", s, s); delete s; }
My best code is written with the delete key.
Not only random, but totally undefined (I count 6 undefined behaviours). Nice one, Prelude.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Well if you want to just be random....
Code:struct main(double ƒ0, int 2ndParameter) [ if(ƒ0 != x) move eax, 2ndParamter + 3rdParameter; otherwise return new main("success"); }
well i didn't mean completely random, but pick something random from an array
>well i didn't mean completely random
We know what you meant. But can you imagine how boring these forums would be if we never had fun and games?
My best code is written with the delete key.