General Information
Student Resources and Information
Interests
|
Random Poetry
Here's my attempt at a Spring poem (click on the "Compose" button):
The procedures for the poetry part are as follows:
to poem
cs rt 90
repeat 5[line pu lt 90 bk 32 rt 90]
end |
to line
label (sentence article adjective noun verb)
end |
to article
op item 1+random 2 [The A]
end
|
to adjective
op item 1+ random 5 [singing vibrant green colourful new ]
end |
to noun
op item 1 + random 8 [brightness light love daffodil snowdrop nest bird life]
end |
to verb
op item 1 + random 5 [sings builds grows changes springs]
end
|
Put in the button control and the green square background yourself.
Notes
Recall that the command random x outputs a random integer between zero and x-1.
For example, random 6 randomly outputs one of the integers 0,1,2,3,4,5.
In the procedures above we use, for instance, 1+random 5. This randomly outputs one of the integers 1,2,3,4,5.
The command item x [...........] selects the xth member of the list [.................].
For example, the command item 1+ random 5 [singing vibrant green colourful new ] randomly selects one of the 5 words of the list [singing vibrant green colourful new ].
The command op is short for output and causes the procedure to "output" the item which has just been selected.
The command sentence makes a list out of its inputs.
For example (sentence article adjective noun verb) makes a list from the outputs of the procedures article adjective noun verb. The round brackets are necessary because the number of inputs to the command sentence is not fixed.
The command label then takes the list created by (sentence article adjective noun verb) as its input.
|