Learn creative coding writing simple programs

56. Silly poet writes absurd things

We had a program that wrote a random adjective and a random noun together. It was printing things like "tall tree" or "sticky sky". We continue changing this program so it can write longer sentences. Until now we had an array with adjectives and another array with nouns. We add three new arrays: articles, verbs and prepositions. This allows us to build rather long sentences.
To print the words we create our own function called write_word(). This function only receives one parameter: an array of words. So if we want to print a random adjective, we use write_word(adj). If we want to print a random preposition, we call write_word(pre).
The function receives the whole list of words. Looks at how many words there are in this list, and prints one of them randomly.

Tags: funny, poetry, sentence, generator, phrase, writer, software, random, poem

Code editor

You can make changes to the code below. Then
Questions and comments are welcome! :) But please try to stay close to the topic of this episode. Use the Processing forums for help with your Processing projects (or hire me for help ;-)