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 xReturns 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.Create a NetLogo program with the following features:InterfaceA slider called angleShould start at 0 and go to 360 in increments of 1A slider called strideShould start at 0 and go to 5 in increments of 0.1Buttons for each of the procedures listed below.Procedures (Make the buttons for all the SetupClear the screen and make one turtle (you can add custom features to the turtle if you wish)wiggle0Turtle procedure with no parameters.Makes a turtle move forward 1 unitMakes a turtle turn right a random number of degrees between 0 and the value of the angle slider.wiggle1Turtle procedure with no parameters.Makes a turtle move forward 1 unitMakes 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.wiggle2Turtle 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 sliderwiggle3Turtle 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 sliderMakes a turtle turn left a random number of degrees between 0 and the value of the angle sliderTest your code using the buttons and slidersWhen 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.