MIHS-Make_A_Tree
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This model draws trees.
HOW IT WORKS
It uses a simple algorithm with a few user-defined parameters to draw (hopefully) coomplex and beautiful images of trees.
HOW TO USE IT
Set the different parameters to whatever values you like. They affect the properties of the tree that is drawn by the algorithm pretty much as you would expect (e.g. a higher width tends to produce thicker branches), but the interactions between different settings of the parameters could produce unexpected results.
THINGS TO NOTICE
How does changing a parameter affect the final shape of the tree that the algorithm draws? How do different parameters seem to interact with each other? Which combinations produce the most realistic trees? The most interesting or unusual trees? Can you produce particular varieties of tree shapes you would see in nature?
THINGS TO TRY
Controlled Experiments (changing only one variable at a time to see that variable's effect on tree shape)? Go to extremes (setting parameters to various, perhaps randomly determined, extremes of high and low)? Try to adjust the settings to produce different specific tree shapes (e.g. bushy shrubs, tall firs, spreading oaks)?
EXTENDING THE MODEL
Change the algorithm. Change the parameters and/or add new ones. Introduce new options.
RELATED MODELS
Try some of the models inside the "Art" folder in the Models Library.
CREDITS AND REFERENCES
Search for "MIHS20-MakeATree" on the Modeling Commons
Comments and Questions
;; MAKE A TREE 2.0 ;; 22 March 2020 ;; by Larry Bencivengo ;; major change in algorithm - fewer branches start thicker & "hatch" smaller branches ;; new branches have same # of births as parent, but dist = 0 ;; The Parameters used by the tree-drawing algorithm: ;; generally, the branches will grow for longer with a greater height ;; generally, there will be more branches when branching is higher ;; generally, the branches will spread out more laterally when spread is higher ;; generally, the trunk and branches will tend to be thicker when width is higher ;; the branches draw the tree as each one climbs into the air independently ;; randomly "hatching" new branches as it goes globals [ number-branches new-color] ;; the user-determined parameters influence the way each branch climbs and interacts with other nearby branches breed [ branches branch ] branches-own [ dist ;; dist keeps track of how far the branch has traveled since its last "birth" births ;; each time the branch branches off, a new branch is hatched with dist = 0 new-heading ;; place-holder variable to hatch new branches new-distance ;; place-holder variable to hatch new branches ] to setup clear-all ;; the number of branches depends partly on the parameter width set number-branches 10 + random ( 3 * width / 10 ) create-branches number-branches [ ;; color set new-color 35 + random ( color-range ) - random ( color-range ) ifelse new-color > 140 [ set new-color new-color - 140 ] [ if new-color < 0 [ set new-color new-color * -1 ]] set color new-color setxy ( 0 + random ( width / 20 ) - random ( width / 20 ) ) ( min-pycor ) set heading 0 set pen-size ( 7 + width / 10 ) pen-down ] reset-ticks end to draw setup loop [ ask branches [ grow ] ask branches [ check-death ] tick ;; check for tree done drawing if count branches = 0 [ stop ] ] end to grow ;; check for branching if random ( 200 - random ( 100 - height ) ) < ( dist * branching / 20 ) [ ;; the number of times the branch will hatch new, smaller branches is limited if births < random ( 3 + branching / 10 ) [ set dist 0 ] set births births + 1 ifelse pen-size > 1 [ set pen-size pen-size - 2 ] [ ifelse pen-size = 2 [ set pen-size 1 ] [pen-up ]] ;; branch either right or left (equal chance) ifelse random 100 < 51 [ set new-heading ( heading + 15 + ( random spread / 2 ) * 1.5 )] [ set new-heading ( heading - 15 - ( random spread / 2 ) * 1.5 )] hatch 1 [ set heading new-heading ] ] ;; grow one unit rt random 10 lt random 10 forward 1 set dist dist + 1 end to check-death if births * dist > 5 * random height [ die ] end to reset set height 50 set color-range 50 set branching 50 set spread 50 set width 50 end
There is only one version of this model, created over 5 years ago by Larry Bencivengo.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
MIHS-Make_A_Tree.png | preview | Preview for 'MIHS-Make_A_Tree' | over 5 years ago, by Larry Bencivengo | Download |
This model does not have any ancestors.
This model does not have any descendants.