Project Folders
Teacher Resources
Student Resources
How Do I?
Site Map
Our Team

ant hill 1 2 3 4 5 6
Ant Hill Expert 5
7 KB

Goal:   The ants emerge from an ant hill and return to it.


Vocabulary:   st, clickon, clickoff, repeat, when, touching?, stopall

Project Map

to go_home
t1, clickoff towards "anthill repeat 3 * distance "anthill [fd 1 / 3]
anthill, st
when [touching? "t4 "anthill] [t4, fd 10 stopall]

to go
t1, clickon
forever [ t2, towards "t1 fd 1 / 20 * distance "t1
         t3, towards "t2 fd 1 / 20 * distance "t2
         t4, towards "t3 fd 1 / 20 * distance "t3]
wait 10 anthill, ht
forever [ clean
         compass, setpos [-195 -79]
         seth direction
         fd 43 bk 43
         settext1 heading]

to ouch
ask [text2 text3 text4 text5] [launch [showtext wait 3 hidetext]]


This project uses a turtle wearing an anthill shape so that the ants can appear to go into the anthill.

  1. Hatch a new turtle named anthill and give it the shape of an anthill (with some clear space above, so that the top of the ant hill is slightly above the middle of the shape).   Stamp it on the background and leave it sitting on top of its stamped image, so that when the anthill turtle is hidden, we will still see the anthill but the ants can crawl over it instead of behind it.  

  2. Type freezebg (freeze background) in the command center so that this stamped anthill will not get erased after the clean command when the compass needle is erased and redrawn.

  3. Open turtle t1's backpack set its OnClick rule to:
    fd speed / 10 seth direction -- set to Forever.  
    This instruction is launched with clickon in the go procedure and is cancelled with clickoff in the go_home procedure.   In this way, turtle t1 can be given a new set of instructions for returning to the ant hill in the go_home procedure.   All of the other turtles will follow their leader back to the ant hill.

  4. Repeat 3 * distance "anthill [fd 1 / 3] is a way of sending the turtle the exact distance to the turtle named anthill, moving somewhat slowly.   If we just wrote fd distance "anthill the turtle would go the same distance but would seem to leap there.   Repeat distance "anthill [fd 1] would also move the turtle the same distance to the anthill, moving forward one turtle step at a time, which is still rather quickly.   Repeat 3 * distance "anthill [fd 1 / 3] multiplies the number of repetitions by 3 while moving turtle t1 forward 1/3 of a turtle step with each repetition, causing the turtle to move more slowly.   After turtle t1 reaches the anthill, it stops moving, and the other turtles eventually catch up to it, hiding behind the anthill.

  5. In the go_home procedure, st means "show turtle."

  6. When checks continually to see if the condition in the first set of brackets is true.   When it is true, the computer will run the commands in the second set of brackets.  

    When [touching? "t4 "anthill] [t4, fd 10 stopall] checks to see if turtle t4 is touching the anthill turtle.   When they are touching, turtle t4 moves forward 10 turtle steps to get hidden behind the anthill, and then all processes stop.   Turtle t4 is the last turtle to reach the anthill, so now the turtles have all returned home.

  7. Make a go_home button and try it!

What If?
What happens if you delete the fd 10 near the end of the when command?
What happens if you delete the stopall at the end of the when command?

Can you adjust the speed of the ants returning home?
Can you make a new message appear when all of the ants get home?
Did you notice that the ants in Project 5 move faster than the ants in Project 4, even though the go procedure is nearly identical? Can you adjust the go procedure or t1's instruction so that the ants move at a similar speed in both projects?

On Your Own - Project Ideas
Make different animated characters come out of one spot and return to it.   Examples: bees swarming out of a hive, bats flying out of a cave, fireworks bursting (use a different turtle with its pen down to draw each line as many turtles spray out from one point)

© copyright 2001 - 2016  OpenWorld Learning.   All rights reserved.