What
is it?
|
Drawing
recursive trees is a standard project in programming languages
like Lisp and Logo. StarLogo makes possible new types of recursive
trees that are more "natural" and easier to understand. Rather
than using a single turtle to draw the entire tree, the StarLogo
approach "hatches" a set of new turtles to draw each level
of the tree.
|
How
to Use It |
Click
the setup button to create the root.
Click the tree button to draw a StarLogo tree.
Click on the one step at a time button to draw
one level at a time.
The
dist slider controls the length of branches
in the tree.
The angle slider controls the angles between
the branches.
The depth slider controls the depth of the
tree.
The x-coord and y-coord sliders control
the position of the root.
The variation slider controls the amount of
randomness in the tree placement.
|
 |
|
Things
to Notice |
Each
level of the tree is drawn in parallel. That is, the program
draws the trunk, then the next two branches, then the next
four sub-branches, and so on. In the standard Lisp/Logo approach
for drawing recursive trees, the drawing order is very different:
the program draws all of the leftmost branches of the tree
and then works its way over until it draws all of the rightmost
branches. The StarLogo approach seems much more natural and
intuitive.
|
Explorations |
- By
adjusting the sliders, you can make some patterns that look
more like "creatures" than trees. Try it.
|
StarLogo
Features |
In the
treestep procedure, the "counter" for the recursion
is kept as a local turtle variable, not as a local procedure
variable.
|