This is a graphical program which illustrates certain StarLogoT programming techniques that can be used in a variety of situations.  It is a turtle model; patches merely provide blue background. 
The main players are four breeds: bubble, fish, jellyfish, crab and seaweed.   Each breed knows how to paint itself with a given color and how to move around the screen.  For instance, here are the bubble procedures called bubble.rise and bubble.paint: 
; { bubble }

to bubble.rise 
  bubble.paint background 	 ;;turtle paints itself blue, ie, disappears
  setheading 0
  forward 0.5
  if ycor > screen-edge-y - speed [die]
  bubble.paint black   ;;paints itself black in its new position

to bubble.paint :color			;;turtle draws its shape
  setcolor :color
  repeat 10 [left 36 forward 0.2 * pi * speed]

(Similar naming conventions are used with other breeds.)

In the bubble.paint procedure, a turtle is asked to crawl around a circle holding its pen down.  Notice that the turtle returns to its original starting point and heading after the paint method is complete.  As long as this is true, any drawing will work.    
	In bubble.rise procedure, turtles first paint themselves with the background color, thus erasing themselves from the screen.  Then they move up a little and re-paint themselves with their color (black for bubbles).  Notice that if a turtle doesn't start at its original position and heading, it will not be able to erase itself with the paint procedure.

The painting and moving procedures for other agents are more complicated, but the underlying principle is the same.  The agent erases itself, moves, then repaints itself, creating the illusion of movement. 


Set it up by pushing the SETUP button once.  This will randomize the positions of fish, crabs, seaweed and jellyfish.  You can control the number of agents of each kind with the appropriate sliders.  Then press RUN.


Try to introduce your own breeds into the model.

Can you figure out where the bubbles come from? 


StarLogoT turtle shapes are limited to being on one patch.  This allows for larger shapes that move like agents.  

Notice how crabs change their heading:

to crab.changeheading :frequency
  if (random :frequency) = 0 [setheading heading + 180]

The variable ":frequency" is set to 100 in the procedure ask.crab.  

This is a snippet of code that you might use whenever you need agents to change their variables independently with random frequency.