MIHS-Make_A_Tree
Model was written in NetLogo 6.0.2
•
Viewed 106 times
•
Downloaded 11 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;; 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 4 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 4 years ago, by Larry Bencivengo | Download |
This model does not have any ancestors.
This model does not have any descendants.