MIC
Pat O'Sullivan
Department of Mathematics and Computer Studies
Mary Immaculate College, Limerick, Ireland

General Information

Student Resources and Information

Interests

Random Art

We can use Logo's random number generator to produce some random "art". The following is a simple example. You can vary it a little by changing the shape from a square to any other shape you wish and later we will learn how to introduce further variation.
In this example we simply have a random turtle turn rt random 360 followed by a forward movement of random size betwee 0 and 99 fd random 100 and then the turtle draws a filled square. The fill colour is randomised by setfc random 16

My suggestion is that such random "art" and random "poetry" can be used to initiate a discussion on why we might consider one outcome "nicer" than another or whether there is any possible message conveyed by a piece. etc.

My main procedure is called draw. You can try out the Java equivalent below (type draw into the text box below - do it a few times). The command cs also works here if you want to get a clean pallette again:

The procedures used are:

to draw
repeat 50[pu rt (random 360) fd (random 100) setheading 0 setfc (random 16) pd ssquare] end
to ssquare
repeat 4[fd 50 rt 90]
pu rt 45 fd 10 fill bk 10 lt 45 pd end

The command setheading 0 sets the turtles heading to 0. The turtle's heading is the size of the angle it makes with the vertical. The command is necessary here if you want all the squares to be horizontal because we cannot anticipate the turtle's heading after the command rt random 360.

 
Department Home
Home
The information found on personal pages should not be considered official material from Mary Immaculate College and the College does not accept any responsibility for its accuracy or otherwise.