### lectures and homework

 Remember to use the Discussion Board: (Via Email, or as a forum)https://groups.google.com/a/stuy.edu/forum/#!forum/konstantinovich-introcs2016

#### 2017-01-23

posted Jan 23, 2017, 6:59 AM by Samuel Konstantinovich   [ updated Jan 23, 2017, 6:59 AM ]

 Survey!https://goo.gl/forms/kmSkiW9ApsxI5cT43Some Demos-Patrick's stuff -Winners of the competition:    Honorable Mentions:        Raunak, Cooper, Alex(Liu)    Best in show:        Hanna(Yang)

posted Jan 17, 2017, 5:30 PM by Samuel Konstantinovich   [ updated Jan 17, 2017, 5:30 PM ]

 Final Exam practice ( ONLY look at the Netlogo section of the old finals)2012 Spring:https://docs.google.com/viewer?a=v&pid=sites&srcid=c3R1eWNzLm9yZ3xob21lfGd4OjJmODg2ZjVkZmU1NGYyMGQ2013 Fall:https://docs.google.com/viewer?a=v&pid=sites&srcid=c3R1eWNzLm9yZ3xob21lfGd4Ojc1ZmY1YWI2NzRkNmNkZTEReference sheet (you will get this on the final)

#### 2017-01-17

posted Jan 17, 2017, 6:13 AM by Samuel Konstantinovich   [ updated Jan 17, 2017, 6:13 AM ]

 A. The final exam will NOT contain scheme questions.B. While we set up here is a set of review question with lists: (complete for homework)1. Given a list nums that contains integers in no particular order and an integer value:Write a function   to-report countValue [ nums value ]This reports the number of times value appears in the list of numbers.for example:show countValue [3 1 9 3 4 2 3 4 3]  3   > 4show countValue [3 1 9 3 4 2 3 4 3]  4   > 22. Write a function to initializeWorld [ n ]This causes n turtles to be distributed around the world randomly. This should happen in such a way that no two turtles are on the same patch, and there is an equal probability that the turtles start on each patch.

#### 2017-01-13 Reminder!

posted Jan 13, 2017, 1:24 PM by Samuel Konstantinovich   [ updated Jan 13, 2017, 1:24 PM ]

 1. Final project submission is Tuesday End of school day.2. You MUST have your prototype Tuesday in class, to be handed in.3. You must be prepared to show off all of the things that work, how your project works.4. Your project should be 99% done if not 100% done. Minor bugs will be overlooked!

posted Jan 11, 2017, 7:25 AM by Samuel Konstantinovich   [ updated Jan 11, 2017, 7:25 AM ]

 Documentation Tab - Look at other models and see how the documentation tab is written.Your final project needs (minimally) the following parts in documentation:1. What is it2. How it works3. How to use it4. Things to note5. CITATIONS IF NEEDED (any help you got, code/libraries you used)6. A breakdown: Which group members worked on EACH PART of the project. (A log of who wrote code for each part of the project)Starting 1/11/17You should comment each function that you write by adding the date and what you did to it;Bob Kim; 10.12.16 wrote function including features A and B; 10.13.16 re-wrote function for speed;Ann Mikuchi; 10.15.16 added feature Dto main-part blahend

#### 2016-12-23 HW Form

posted Dec 23, 2016, 7:05 AM by Samuel Konstantinovich   [ updated Dec 23, 2016, 7:05 AM ]

 Final Project General Info Survey:https://goo.gl/forms/57rmXgdiXyTycm753

#### 2016-12-22 Prototype

posted Dec 22, 2016, 6:05 AM by Samuel Konstantinovich   [ updated Dec 22, 2016, 6:48 AM ]

 Regarding final projects:-Please let me know if your partner is non-cooperative.-Please let me know if you and your partner cannot resolve a conflict.-If you wait until the last minute to tell me you have partner issues, I will not be able to do anything. Prototype: Due the Wed after you get back from break, it can be updated afterward, but I want to see that you have it. This will be 20% of your final project grade. It should look like you put serious effort into it. If it looks like you did this assignment on the train coming to school or rushed it the night before, I will grade you accordingly. Prototype Format Document:https://www.dropbox.com/s/x4xcomc9poc28xg/Prototype.pdf?dl=1-The purpose of the document is for   a. Come together with your partner and make a clear picture of what you BOTH want to do.    b. Explicitly describe the behavior of your project so I can tell you if there are potential problems.    c. Make clear expectations public so you have guidelines to follow and don't cut features for no reason.   d. Have the document in class when you are working so I can reference it when I see your group.-There should be absolutely NO CODE!-A timeline of features to be added is nice, prioritize by importance-Describe what your minimum viable product would be. This is what you want to get working ASAP because it means you can demo a working project.sentence - add two lists to make a new listword - add two strings to make a new string, if you add a non-string, it will become a string.Mini Lab: Lists!Make setup / go buttons. Make go forever.Now use this base code:```turtles-own [ meetings mode ] ;;mode is the state of the turtle ;;meetings is a list of all the turtles they have interacted with or "met" to setup ca reset-ticks ask n-of 50 patches [ sprout 1 [ set size 2 set mode "social" set meetings [] ] ] end to go ask turtles[ set label word who word " " meetings wiggle ;;when a turtle is in "anti-social" mode they have ;;a 1/100 chance to turn social ;;anti-social turtles are red. `````` ;;when a turtle is in "social" mode they try to meet other ;;turtles on the same patch with the meet-others command. ;;social turtles are lime colored. `````` ] tick end to wiggle fd .1 rt random 10 lt random 10 end to meet-others let friends [] ;;have other turtles on the same patch add ;;their who number to the friends list. `````` ;;combine the freinds list with your meetings list ;;and that will be your new meetings list. `````` ;;after meeting others, the turtle becomes "anti-social" ````end`

#### 2016-12-21 HW!

posted Dec 21, 2016, 6:46 AM by Samuel Konstantinovich   [ updated Dec 21, 2016, 8:50 AM ]

 Goal: Lists, what are they good for? HW: Bring in a hard copy tomorrow-Look through 3 different models in the NetLogo models library that utilize lists.-Explain how they are used (what they are for)-List things that you learned from each of the models.Agent sets are similar to lists in the sense that they contain 0 or more agents. They are limited however!Lists can store an ordered set of items.The items can be agents or numerical values.The lists can be used to go through the items in a sequence, or until some event happens.Lets do some work with lists...CODE SAMPLE FROM CLASS:turtles-own [history]to setup  ca  crt 1[    set history []    pd    move     ]endto pick-direction  set heading one-of [0 90 180 270]endto add-coordinate  set history lput xcor history  set history lput ycor historyendto move    add-coordinate    pick-direction    fd 1endto back-up  ifelse length history > 0  [    let y last history    set history but-last history    let x last history    set history but-last history    setxy x y  ]  [ show "No moves to back up" ]end

#### 2016-12-20

posted Dec 20, 2016, 6:11 AM by Samuel Konstantinovich   [ updated Dec 20, 2016, 6:11 AM ]

 1. READ the notes on lists, and experiment with them in netlogo. 2. LOOK at some models with lists in them, or code examples with lists!3. TRY to make a turtle remember the patches it has been on, have the turtle show it's list to you so you can see if it works. (informal but good  practice, if you can do this, then you win!)Complete list commands: (optional if you are interested)https://ccl.northwestern.edu/netlogo/docs/programming.html#listsSubset of list commands with some tweaks:list - create a list out of 2 elements (more elements or fewer requires parenthesis)lput / fput  - creates a copy of the list with an extra element at the last/first positionitem - gives you the element at the index specifiedConstant listsYou can make a list by simply putting the values you want in the list between brackets, like this: `set mylist [2 4 6 8]`. Note that the individual values are separated by spaces. You can make lists that contain numbers and strings this way, as well as lists within lists, for example `[[2 4] [3 5]]`.The empty list is written by putting nothing between the brackets, like this: `[]`.Building lists on the flyIf you want to make a list in which the values are determined by reporters, as opposed to being a series of constants, use the `list` reporter. The `list` reporter accepts two other reporters, runs them, and reports the results as a list.If I wanted a list to contain two random values, I might use the following code:```set x list (random 10) (random 20) ```This will assign to the variable  `x ` a list with two different random integers each time it runs.To make longer or shorter lists, you can use the `list` reporter with fewer or more than two inputs, but in order to do so, you must enclose the entire call in parentheses, e.g.:```(list random 10) (list random 10 random 20 random 30)```CHANGING LISTS:  (read the examples of lput/fput in the dictionary)Lists cannot be changed, but you can make a new list, and assign that to the same variable if you like. think: if x is 5set x x + 1  ;this does not change the number 5, it changes which number is stored inside of x.To add an item, say 5, to the end of a list, use the `lput` reporter. (`fput` adds an item to the beginning of a list.)let stuff [1 2 3 4]set stuff lput stuff 5   ; this does not change the list stored in stuff, it makes a new list and puts that list in stuffshow stuff                  ; shows [1 2 3 4 5]OTHER WAYS TO MAKE LISTS:The `of` primitive lets you construct a list from an agentset. It reports a list containing each agent's value for the given reporter. (The reporter could be a simple variable name, or a more complex expression -- even a call to a procedure defined using `to-report`.) ` [size] of turtles ;reports a list like [1 1 1 1 2 3 1]`` [count turtles in-radius 2] of turtles ;reports a list like [1 3 1 1 1 1 3 3]`OTHER WAYS TO USE LISTS:Iterating over listsIf you want to do some operation on each item in a list in turn, the `foreach` command.`foreach` is used to run a command or commands on each item in a list. It takes an input list and a command name or block of commands, like this:```foreach [1 2 3] show => 1 => 2 => 3 foreach [2 4 6] [ crt ? show (word "created " ? " turtles") ] => created 2 turtles => created 4 turtles => created 6 turtles ```In the block, the variable `?` holds the current value from the input list.Here are some more examples of `foreach`:```foreach [1 2 3] [ ask turtles [ fd ? ] ] ;; turtles move forward 6 patches foreach [true false true true] [ ask turtles [ if ? [ fd 1 ] ] ] ;; turtles move forward 3 patches```

#### 2016-12-19 - Final Project

posted Dec 19, 2016, 6:58 AM by Samuel Konstantinovich   [ updated Jan 5, 2017, 7:35 AM ]