Programming the turtle


The Logo programming language for children was created by Seymour Papert at MIT in the seventies.
The turtle moves like you and me.
It starts from where it is and goes forward, backward, right or left.
You can move the turtle by tapping the buttons at the left of the screen.
When the “pen” is down, the turtle draws pictures.
This game is a powerful introduction to geometry and programming.
Click here to see it in the iTunes store—where you can buy it for $1.99.


                 


When you tap the buttons at left, the turtle moves forward 100 pixels and then turns right 90 degrees. Doing it four times draws a black square over the blue one.
Move the mouse over the picture to see another way to draw the square. When you tap the turtle, it moves by following the instructions of the “script” at right.
The Logo language has two basic commands: fd and rt. Then it uses words like repeat and if.

 
   
 

Logo scripts are very simple but can be quite powerful.
In the Mad Logo program, the turtle draws many strange and beautiful geometrical figures.
The example above shows a very simple shape and the custom command, snowflake, that lets the turtle draw the shape.
Move the mouse over the picture to see what happens when you repeat a small version of the shape many times.
This manner of repeating shapes at a smaller scale is the core idea of what mathematicians call “fractals.”
Nature seems to work this way quite often.
 
   

 


This turtle race is programmed (more or less) with a Logo script.
The buttons at left control the turtle. You can move faster or slower, turn 15 degrees left or right.
If you go too fast and don’t turn soon enough, you crash. Your speed falls to zero and you lose lots of time. But if you drive too carefully, you also lose lots of time.
The number of steps appears in the white panel. Good scores are entered into the game’s hall of fame, which is displayed when you tap the white panel.
Move the mouse over the picture to see the two-turtle version of the game.