Courses‎ > ‎Intro to CS - Full Year‎ > ‎Fall‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

Work 07: 11/1

posted Nov 1, 2019, 7:43 AM by JonAlf Dyrland-Weaver
In class you've seen me use random in NetLogo. Here is how it works:
  • random x
    • Returns a random integer between 0 and x, excluding x.
    • For example, random 3 could return 0, 1 or 2.
    • For more information on random (and other NetLogo commands) check the documentation.
  1. Create a NetLogo program with the following features:
    1. Interface
      • A slider called angle
        • Should start at 0 and go to 360 in increments of 1
      • A slider called stride
        • Should start at 0 and go to 5 in increments of 0.1
      • Buttons for each of the procedures listed below.
      • Procedures (Make the buttons for all the 
      • Setup
        • Clear the screen and make one turtle (you can add custom features to the turtle if you wish)
      • wiggle0
        • Turtle procedure with no parameters.
        • Makes a turtle move forward 1 unit
        • Makes a turtle turn right a random number of degrees between 0 and the value of the angle slider.
      • wiggle1
        • Turtle procedure with no parameters.
        • Makes a turtle move forward 1 unit
        • Makes a turtle turn right a random number of degrees between 0 and the value of the angle slider.
        • Makes a turtle turn left a random number of degrees between 0 and the value of the angle slider.
      • wiggle2
        • Turtle procedure with no parameters.
        • Makes a turtle move forward stride units (from the slider)
        • Makes a turtle turn right a random number of degrees between 0 and the value of the angle slider
      • wiggle3
        • Turtle procedure with no parameters.
        • Makes a turtle move forward stride units (from the slider)
        • Makes a turtle turn right a random number of degrees between 0 and the value of the angle slider
        • Makes a turtle turn left a random number of degrees between 0 and the value of the angle slider
  2. Test your code using the buttons and sliders
    • When testing, the turtle will move very fast, you can slow down the entire program with the speed slider at the top of the NetLogo window.
    • Answer the following questions in comments at the top of your code (like racket, any line that begins with a ; is considered a comment and will be ignored with the program is run.
      • Run wiggle 0 and wiggle 1 multiple times with the angle slider set to values below 100. How does the turtle behave differently between the two procedures?
      • Run wiggle 0 and wiggle 1 multiple times with the angle slider set to values above 180. How does the turtle behave differently between the two procedures?
      • Run wiggle2 and wiggle3 with varying values for stride and angle. What happens when stride is less than 0? More than 1?
      • Random movement is a big part of many NetLogo programs. Which of the wiggle procedures do you think is the most useful for random movement, and why? Which do you think is the least useful, and why? 
Submit this as wiggles.
Comments