Robotic Kids and Programmable Turtles
Lately G and S have enjoyed playing “the Robot Game”. Here are the rules: They stand still waiting for you to give them a command, you tell them what to do and they do it.
Sounds like a parents dream right? Not quite. If you say “take five steps forward” they will mechanically walk forward counting each step. If you tell them “turn right”, they will turn right. But if you say “clean up this mess” or “We’ve been out here for hours, it’s freezing, let’s go home!” they will reply with a slow, robot-like voice “do not know that command”.
I think they got the idea from Cyberchase.
So I was very happy to find that drj11 is building an implementation of logo that works in your web browser. You see, logo is a programming language centered around a little turtle that appears on your screen. You can type in commands to make the turtle move around and draw lines. If you type “forward 100″ the turtle will move 100 pixels forward and draw a line on the way. If you type “right 90″, the turtle will turn right 90 degrees. So my boys now have their own robot.
If you are familiar with logo, have a look at Curly Logo (works on Firefox and Safari, not Internet Explorer). If your memory is vague, a quick look at his brief documentation will help you get started. You can find his contact information there, and please let him know what you like and what you find confusing, he would love feedback!
If you’re not familiar with logo, I highly recommend that you or your kids play around with it some. It is a great introduction to programming that gives you immediate feedback. It is also a great way to learn some basic facts about Geometry. To get you started, I give you a couple of simple examples. You can put these directly into Curly Logo and watch them in action.
Let’s start by drawing a square. To do this we need to move forward some, turn 90 degrees, move forward again, and so on. Here is what the logo program looks like:
forward 100
right 90
forward 100
right 90
forward 100
right 90
forward 100
right 90
This works but it is a little cumbersome. We shouldn’t have to type the same thing over again and again, and we don’t have to. Try this:
repeat 4 [fd 100 rt 90]
We just told it to repeat these commands 4 times, much easier, right? I also typed in the shorter forms of the commands: ‘fd’ is the same as forward’, and ‘rt’ is the same as ‘right’. These short forms were much easier for my kids to use.
But now we might want to draw a bigger square. We could just type the same commands again, but that gets tedious. We want to define a function. Here’s how:
to square size
repeat 4 [fd size rt 90]
end
Now whenever we want to draw a square, we can just type something like
square 200
and get a square. You say you want different colors? The command ’setpc’ will help.
setpc 1
square 50
will give you a small red square. Here’s the pop quiz:
- draw an orange triangle
- draw a green pentagon
- extra credit: draw a purple pentagram inside that pentagon
For some fancier tricks, have a look at these two examples (courtesy of drj11):
Draw glasses on Ingrid Bergman
I’ll post some more examples and put together more links to resources later, but this should be a good start.
[Update: Here is a good list of basic logo commands to get you started]