Learn programming 56: Silly poet writes absurd things

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
128 views
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Sep 30, 2011

Fun programming with Processing, episode 56. 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.

www.funprogramming.org

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (0)

Sign In or Sign Up now to post a comment!
Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more