2015-12-04 Wrap Up Tree

posted Dec 4, 2015, 5:46 AM by Samuel Konstantinovich   [ updated Dec 4, 2015, 5:46 AM ]
Goal: Wrap up trees 
(Just in time for the tree vendor at the corner across from McDonalds)

ALTERNATE Tree Solution:
to advanced-go
  cd
  ask turtles
   [  
     hatchy-tree tree-size
   ]
end

to hatchy-tree [ n]
  if n > 0[
    pd
    fd 3
    hatch 1 [ rt 30 hatchy-tree n - 1 die]
    hatch 1 [ lt 30 hatchy-tree n - 1 die]
    bk 3
  ]
end

LabN02 Solution:
to quad1
   wiggle turtle-speed 0
   set color red
   if size >= 1.1 
   [ set size size - 0.1]
end

to quad2
  wiggle 2 * turtle-speed max-turn-angle
  if color mod 10 <= 8.9
  [ set color color + 0.1]
  if size >= 1.2 
  [ set size size - 0.2]
end

to quad3
  wiggle turtle-speed max-turn-angle
  set color 5 + 10 * random 14
  ;set label color ;to see if this works I used the label
  
  if size <= 4.9 
  [ set size size + 0.1]
end

to quad4
  wiggle 2 * turtle-speed max-turn-angle
  if color mod 10 <= 8.9
  [ set color color + 0.1]
  if size >= 1.1 
  [ set size size - 0.1]
end


to go
  every 1.0 / 30.0[
    ask turtles [ 
      act
      ;set label quadrant;to check the quadrant I used the labbel
    ]
  ]
end


;turtle context command
to act
  if quadrant = 1
  [ quad1 ]
  if quadrant = 2
  [ quad2 ]
  if quadrant = 3
  [ quad3 ]
  if quadrant = 4
  [ quad4 ]
end

;turtle context command
to-report quadrant
  if xcor > 0 and ycor > 0
  [ report 1]
  if xcor <= 0 and ycor > 0
  [ report 2]
  if xcor <= 0 and ycor <= 0
  [ report 3]
  report 4
end



Comments