Generate random words

Hi,

I'm new programming in arduino, and I'm trying to make a program that generates a thousand random words and then print them in serial, how could generate a thousand random words ?.

Regards.

Sabths: Hi,

I'm new programming in arduino, and I'm trying to make a program that generates a thousand random words and then print them in serial, how could generate a thousand random words ?.

Regards.

  1. You would need a source of words that you can randomize.
  2. You need to know how many words you have.
  3. You need to understand how to use random number https://www.tutorialspoint.com/arduino/arduino_random_numbers.htm

Do they need to be real (ie from a dictionary) words, or random selections of letters?

There may be some details online of the algorithm used in the game Elite to generate random words

You may need more memory, especially if there are more than 1000 words to choose from...

And, that's a LOT of "typing" to create that list within your code!

that generates a thousand random words

I assume these are real words that you can find in the dictionary, not just random letters and made-up "words"? You can't "generate" real words without also generating lots of garbage.

It's easier if you want to generate garbage-nonsense "words". The [u]ASCII[/u] characters are from a=97 to z=122 (decimal), so all you have to do is generate random length strings (within whatever length constraints you want) of random chars between 97 and 122.

You can use an array of strings (one word per string) (or a [u]vector[/u] of strings).

Then, you can randomly select the array pointer (which is a "number").

If you want to make it impossible to select the same word twice, there are algorithms for "random selection without replacement". I forgot how these algorithms work, but one way to do it is to delete the word from the array (or vector), shifting-up everything below it and updating the number of items in the array.

AWOL: There may be some details online of the algorithm used in the game Elite to generate random words

You made me squirm there. I was all hands up in the air, back at school going 'Please Miss I know that I know that' :)

A small bit of research and memory prodding and it all comes back to me - Francis Spufford wrote the book “Backroom Boys” which describes the development of the Elite game.

[quote author=Mr Spufford] They could encode all the information on a particular solar system in a relatively short row of digits. That number, it occurred to them, wouldn’t have to be stored if it were an iteration in a Fibonacci sequence – or a Fibonacci-like sequence, anyway. All you would need would be a starting point, a rule for doing the iterations, and a mechanism for extracting the information from the number.[/quote]

I remember reading that book some 25 years ago - great stuff. Thanks for bringing that all back to me.

8)