StarLogo Project:

Tree

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 TREE button to draw a StarLogo tree.

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.

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.

Modify the underlying program to add some randomness. What changes are needed to make the tree look more like a "real" tree?

STARLOGO FEATURES

In the treestep procedure, the "counter" for the recursion is kept as a local turtle variable, not as a local procedure variable.

Run StarLogo Tree project

Back to Project List

Back to StarLogo Homepage