|
||||||
| General Programming Non language specific and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Does anyone already have code for it? Thanks! |
|
|||
|
If you really want a good generator, the only thing you can use is mother earth. Put up some engine, that gets wind speed, and calculate from that. The wind speed is very random, and if you combines it with time, it will be even more random. Instead of wind, you could use something else, like sound, or everything else. Another, and easier way, is to look at this: Eternally Confuzzled - Using rand() |
|
|||||
|
For what you're describing, you just need to use the random number generation provided by most languages to generate an integer, and display the corresponding phrase (possibly stored in an array).
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. My CodeCall Blog | My Personal Blog |
|
|||||
|
Like WingedPanter said: Have your phrases stored in an array. Use the random number generator provided with your language to pick an array index at random. Display the phrase at that index. Random number generators usualy give you a random double-precision number between 0 and 1, so you would do something like: Code:
phrase = phrase_array[(int)(random()*size_of_array)];
__________________
My fun, friendly online games website: Cygnet Games My Squidoo page on Cygnet Games. |
|
|||||
|
Quote:
Here is an easy way to do it in php: Generating Random Numbers using PHP |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Random Generator of Unequal Numbers | Paradine | PHP Tutorials | 0 | 08-26-2007 02:11 PM |
| Floating Point random number generator | Paradine | PHP Tutorials | 0 | 08-26-2007 02:09 PM |
| The latest program i wrote!! | A.N.H | Java Help | 1 | 04-30-2007 02:36 PM |
| Need help w/ word count program (ASAP) | siren | C and C++ | 1 | 04-23-2007 08:14 AM |
Algorithms and Data Structures
Programming Language Popularity
Code Collaboration
Podnet IRC Network
AmpHosted
Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%