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
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus