2017-10-23 HW14

posted Oct 23, 2017, 6:13 AM by Konstantinovich Samuel   [ updated Oct 23, 2017, 10:25 AM ]
HW: Update your lab (directions to be posted by the end of the day)
-Use if statements to add the following features...
   Sheep and Cows both move.
      Sheep always turn twice as much as cows.
      When an animal is on the left HALF of the screen, they move three times as fast.
   Trees do not move, but they change to a random shade of "green". 
    Shades of green are between the values:   green - 5 and green + 5. (yes this ignores the color value selector)
-Break this up into separate procedures for sheep, cows, and trees. Make sure you name the procedure something appropriate. 
-Submit this on the homework server as a comment. b

If you would like to be part of the longstanding tradition of parent-teacher conference volunteers (goons) then please email me. We can suffer the long hours together! You can hang out with other volunteers, and hear my ridiculous comments on a variety of things!

PTC Volunteer 2017 FALL
1. Which day can you come? 
 Thursday: 5:15-8pm 
 Friday: 12:45pm - 3pm 
2. Can you bring a laptop?

Goal: Animated lab.

LAB: Start with this base code:

to wiggle [speed angle]
  lt random-float angle
  rt random-float angle
  fd speed

to setup
  crt 30[   init-cow    ]
  crt  2[   init-tree   ]
  crt 30[   init-sheep  ]
  ask turtles[pd]

to init-cow
  set shape "cow"
  set color random-primary-color
  set xcor random-xcor-leftside
  set ycor random-ycor
  set size 2

to init-sheep
  set shape "sheep"
  set color random-color
  set xcor random-xcor-rightside
  set ycor random-ycor
  set size 2

to init-tree
  set shape "tree"
  set color green
  set xcor random-float 7 - 3.5
  set ycor random-float 7 - 3.5
  set size 3

to-report random-xcor-leftside
  report min-pxcor + random (max-pxcor - min-pxcor) / 4

to-report random-xcor-rightside
  report max-pxcor - random (max-pxcor - min-pxcor) / 4

to-report random-primary-color
  report 10 * (random 14) + 5

to-report random-color
  report random-float 140

You must complete these tasks, as well as answer all questions in your NOTEBOOK.

0. Add two sliders:
turtle-speed [from 0.01 to 0.5     in increments of 0.01]
max-angle [0 to 90 in increments of 1]

1. Write a go procedure that asks all turtles to wiggle, using the two sliders to control speed and angle.
Notice it moves too fast...

2. Add a setup button, and a forever go button. 

3. Add an 'every' command around the entire body of your go procedure. 
  Try 1/30th of a second, and 1/60th and 1/15th, and see the results. 

Q1. Describe the difference in behavior between every 1 / 60  and every 1 / 15 
Q2. Describe the difference in behavior between max-angle 30 and max-angle 90 

4. Add a new "input" widget called tree-color.
Set the type to color.
This will let you choose a color, so modify the code to initialize your tree to this color.

Q3. Try to make a "chooser" widget for colors with choices red/green/blue. How is this different from the input with type color? Which is preferable and why?