Work

Unless otherwise noted, all assignments are due by 8am the next class day.

All submissions must be made via the homework server: http://bert.stuy.edu/jdyrland/fall2018/pages.py?page=profile

Late homework can be submitted for half credit up until solutions have been posted.

You can find homework solutions here: https://github.com/mks21-dw/racket
                                                                           https://github.com/mks21-dw/netlogo

Work 24: 11/15

posted Nov 15, 2018, 11:38 AM by JonAlf Dyrland-Weaver

Write a NetLogo procedure that will draw a pretty picture, specifically:
  • You must have at least one procedure that changes the color of patches (at least three different colors).
  • At least one procedure that uses at least one turtle to draw something.
  • Include a setup procedure to clear the world and create the turtle(s) you need. 
  • Here is an example of my beautiful masterpiece:


submit this as netlogo0_review

Work 23: 11/14

posted Nov 14, 2018, 9:48 AM by JonAlf Dyrland-Weaver   [ updated Nov 14, 2018, 11:37 AM ]

Write a NetLogo program with the following features.
  • Interface
    • num_reds: slider for the number of red turtles
    • num_blues: slider for the number of blue turtles
    • bomb_drop_chance: slider for % chance turtles drops a bomb
    • monitors to display the number of red and blue turtles.
    • buttons for the setup and go (forever) procedures, using the sliders where applicable.
  • Procedures
    • Setup (you should have this from yesterday)
      • Takes 2 arguments representing the number of red and blue turtles.
      • Clear the world.
      • Create red turtles randomly scattered about the top of the world.
      • Create blue turtles randomly scattered about the bottom of the world.
    • Wiggle
      • Turtles should move forward 1 and rotate randomly as you see fit.
    • Go
      • Takes 1 argument representing the % chance a turtle "drops a bomb"
      • Turtles should wiggle
      • If a turtle lands on a patch of the opposite color (a "bomb"), the turtle should die and the patch should reset back to black.
      • If a turtle lands on a black patch, it should have a chance to change the patch's color to its own, the chance is set by the parameter.
      • Include wait to slow down your program.
    • Also write a reporter to be used by the monitors.
Submit this as redVblue


BUT WAIT, THERE'S MORE!
  • In preparation for Thursday's review session, you may want to do the following:
    • Create a reference sheet that you can use during the exam.
    • Requirements:
      • Regular letter sized paper (8.5" X 11")
      • Your name and class period must be legibly displayed in the upper-left-hand corner of the sheet when held in portrait-mode.
      • You can either hand-write or type up the sheet.
        • If typing, you cannot use a font size smaller than 12point.
      • You may use both sides of the sheet.
    • The reference sheet can maintain any information you'd like.
    • You must hand in the reference sheet to me at the beginning of Thursday's class! If you are absent, a buddy from the class must hand it in for you.
    • You will be given your reference sheets back on Friday.

Work 22: 11/7

posted Nov 8, 2018, 11:32 AM by JonAlf Dyrland-Weaver   [ updated Nov 8, 2018, 11:36 AM ]

On your own, but with consultation of your neighbors when needed, try to recreate the procedures in the following NetLogo program: http://homer.stuy.edu/~dw/netlogo/monitors.html
  1. Phase 1: TO BE DONE BEFORE ANY CODING!
    • Test the buttons & slider out
      • ca is just there for convenience.
    • Using a Key To Success™, answer the following questions:
      • What are the monitors showing?
        • If the monitors all use the same procedure, how would that work?
      • What buttons does the slider influence?
      • How does the slider behave? Why?
      • What is the difference between colorRandomShade and colorRandomShade2?
  2. Phase 2:
    1. Use the info you gathered in Phase 1 to write your own version of the program.
    2. You should have 4 new procedures (not including colorRandom, which you should've done for the previous assignment).
      1. One should report the value used for the monitors.
      2. Separate procedures for colorRandomShade, colorRandomShade2 and gradient.
        1. Remember, slider values should be passed as arguments
    3. Include your answers to the questions from phase 1 as comments at the top of your code.
      1. Like racket, ; is the NetLogo comment operator.
Submit this as monitors

Work 21: 11/2

posted Nov 2, 2018, 10:57 AM by JonAlf Dyrland-Weaver   [ updated Nov 2, 2018, 11:06 AM ]

With your new table buddy, try to recreate the procedures in the following NetLogo program: http://homer.stuy.edu/~dw/netlogo/colorPatchesWeb.html
  1. Phase 1: TO BE DONE BEFORE ANY CODING!
    • Test the buttons out
      • ca is just there for convenience.
    • Using a Key To Success™, answer the following questions:
      • For colorQuad
        • What is true about all the purple patches? 
        • What is true about all the  blue patches?
        • What can you say about all the white patches?
      • For grid
        • What is the difference between the black and white patches?
      • What is the difference between colorRandom and colorRandom2?
      • To answer the following questions, you'll need to test in netlogo
        • How can you tell the coordinates of a patch?
        • There is an arithmetic operator in netlogo called mod. It is used as follows:
          • a mod b - where a and b are both integers (and b != 0).
        • What does mod do?
  2. Phase 2:
    1. Use the info you gathered in Phase 1 to write your own version of the program.
    2. You do not need to use the same exact colors I do, but the colors you choose must behave in the same way they do in my version.
    3. Include your answers to the questions from phase 1 as comments at the top of your code.
      1. Like racket, ; is the NetLogo comment operator.
Submit this as color_patches
(if you want to fix up your crazy_turtles assignment over the weekend, you may do so with no late penalty)

Work 20: 11/1

posted Nov 1, 2018, 11:13 AM by JonAlf Dyrland-Weaver   [ updated Nov 1, 2018, 12:17 PM ]

With your new table buddy, try to recreate the procedures in the following NetLogo program: http://homer.stuy.edu/~dw/netlogo/crazyTurtlesWeb.html

  1. Phase 1: TO BE DONE BEFORE ANY CODING!
    • Test the buttons out
      • pu, pd and clear (ca) are just buttons that call each of those regular commands, they are there for convenience.
      • The forever buttons were designed to work alone, using 2 or more of them at the same time will lead more to confusion rather than illumination.
    • Using a Key To Success™, write down each button (aside from pd, pu and clear), and answer the following question:
      • What context is it in?
      • Is it a regular button or forever button?
      • Does the called procedure make use of a slider?
      • If it is a Turtle button:
        • Are the actions that all turtles do?
        • Are there actions that apply to certain turtles?
      • There is no button for it, but there is a wiggle procedure
        • How do you think it works?
        • What procedures use the wiggle procedure?
  2. Phase 2:
    1. Use the info you gathered in Phase 1 to write your own version of the program.
    2. Include your answers to the questions from phase 1 as comments at the top of your code.
      1. Like racket, ; is the NetLogo comment operator.
Submit this as crazy_turtles

Work 19: 10/29

posted Oct 29, 2018, 12:37 PM by JonAlf Dyrland-Weaver

Write a NetLogo program with the following features:
  • Interface
    • A slider called numSides
      • Should start at 3 and go to a reasonable number (like 20)
    • A slider called sideLength
      • Should start at 1 and go to a reasonable number
    • A slider called angle
      • Should start at 0 and go to 360
    • For each slider, set the initial value to be something that makes sense, play around with the values to see what works well
    • Include buttons for each procedure listed below
  • Procedures
    • Setup
      • Clear the screen and make a turtle (you can add custom feature to the turtle if you wish)
    • regularGon
      • Should work like the regularGon procedure form the previous assignment.
      • Pass the numSides and sideLength slider values into this function when you make the button for it.
    • pattern
      • Should call regularGon and then turn right.
      • Pass the angle slider value into the function when you make the button for it.
      • Make the button for pattern a forever button! - see what happens
submit this as sliders

Work 18: 10/26

posted Oct 26, 2018, 11:22 AM by JonAlf Dyrland-Weaver

Write the following NetLogo procedures:
  • setup
    • observer context
    • should clear the screen and create a single turtle, facing up.
  • square 
    • turtle procedure with 1 parameter
    • commands a turtle to draw a square where the side length is given by the parameter
  • triangle
    • turtle procedure with 1 parameter
    • commands a turtle to draw an equilateral triangle where the side length is given by the parameter
  • hexagon
    • turtle procedure with 1 parameter
    • commands a turtle to draw a regular hexagon (6 sided figure) where the side length is given by the parameter
  • regularPolygon
    • turtle procedure with 2 parameters [n, l]
    • commands a turtle to draw a regular polygon with n sides of length l
Challenge:
  • rightTri
    • turtle procedure
    • commands a turtle to draw a right triangle
  • HA!
    • turtle procedure
    • have a turtle draw "HA!" on the screen.
    • or have the turtle draw any message you'd like
submit this as turtle_draw

Work 17: 10/23

posted Oct 23, 2018, 7:34 AM by JonAlf Dyrland-Weaver   [ updated Oct 23, 2018, 7:35 AM ]

You will have a number of tasks to perform in NetLogo.  To start NetLogo on the school computers open a terminal (shortcut: control-alt-t), and type netlogo at the command prompt.

For this assignment you will use the following commands:
  • observer commands
    • clear-all
    • create-turtles x
    • create-ordered-turtles x
  • turtle commands
    • forward x
    • back x
    • right x
    • left x
    • pen-down
    • set property value
  • Test out these commands via the command center. Make sure to be in the correct context when using them.
  • In a plain text file, write down what these commands do.
Create a turtle and do the following:
  1. Access the property sheet for the turtle.
  2. In the same plain text file as before, for each property:
    1. Write it's name
    2. Describe what it is
    3. Write 2 examples of set commands that will change the property.
When done, feel free to check out the models library (accessible in the File menu) to see all the built in programs NetLogo comes with.

Submit this as netlogo_commands_1

Work 16: 10/22

posted Oct 22, 2018, 1:49 PM by JonAlf Dyrland-Weaver

  • Download NetLogo!
  • Mr. Brooks has created a number of NetLogo tutorial videos. I would like you to watch up to video 2B (about 16 min in total).
    • Videos 1A and 2A have exercises, do them before moving onto the next videos.
    • You may watch more if you'd like, but you do not have to.
    • If the video quality is fuzzy, you can change the resolution by clicking the gear icon on the bottom right side of the video, 720p will give you a much clearer video.
    • The videos can be found here: http://bert.stuy.edu/pbrooks/videos/NetlogoTutorial/NetlogoTutorial.py
    • Put your answers to the exercises in a plain text file to submit.
    submit this under netlogo_1

    Work 15: 10/17

    posted Oct 17, 2018, 1:03 PM by JonAlf Dyrland-Weaver

    1. Read the following article: https://www.vox.com/cards/the-internet/
    2. Answer these questions in a plain text file
      1. What is an I.P. Address?
      2. Why is Tim Breners-Lee important?
      3. What is the last mile?
      4. What does the lock next to a url signify?
      5. What is the IETF, what does it do?
      6. What is ICANN, what does it do?
    submit this under: internet-explained

    1-10 of 25