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/kmSkiW9ApsxI5cT43

Some Demos
-Patrick's stuff 
-Winners of the competition:
    Honorable Mentions:
        Raunak, Cooper, Alex(Liu)
    Best in show:
        Hanna(Yang)

2017-01-17 Practice Updates

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

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   
> 4
show countValue [3 1 9 3 4 2 3 4 3]  4   
> 2


2. 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!

2017-01-11 Project Updates

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 it
2. How it works
3. How to use it
4. Things to note
5. 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/17
You 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 D
to main-part
 blah
end

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:

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 list
word - 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
     ]
end

to pick-direction
  set heading one-of [0 90 180 270]
end

to add-coordinate
  set history lput xcor history
  set history lput ycor history
end

to move
    add-coordinate
    pick-direction
    fd 1
end

to 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#lists

Subset 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 position
item - gives you the element at the index specified

Constant lists

You 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 fly

If 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   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 5
set 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 stuff
show 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 lists

If 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 ]

Updates:
1. Jan 20th: In class Final Exam.
2.About 10 people have not filled out the survey. Do so today, before I get a list of names.
3. If you plan on taking an extended vacation you MUST inform me AND your partner so that you know when you need to get things done
4. Jan 6th is the deadline to discuss issues with your partner. 

Final Project Logistical Guidelines:
1. You will be required to submit 4 versions of your project over time. 
2. You are expected to do work in class AND at home.
3. You should try to get the minimum requirements done early, and play with how your project looks as a last 
3. Your grade will depend on several factors beyond the actual project:
 a-Your prototype. 
 b-Consistent work throughout the 2 weeks. (The procrastination penalty)
 c-Both partners doing a reasonable amount of work. BOTH partners will be penalized if one person doesn't do work. (This can be avoided by discussing the problem with me as early as possible) 
  Note: It is ok if someone goes above and beyond, as long as the other partner contributes a substantial amount. It is NOT ok if one partner does most of the work, and the other does very little.

Final Project Dates:
Dec 19th: Discussion with partner over ideas, and goals. 
Dec 21st: Project Proposal. (a concise description of the project you want to make)
Jan 4th:  Prototypes required in class while you work. This should be an elaborate explanation of your goals, and picture of how you want things to work. Details to follow.
Jan 6th:   HW server Project slot 1 due by 8am. 
Jan 10th: HW server Project slot 2 due by 8am. 
Jan 13th: HW server Project slot 3 due by end of school day. 
Jan 17th: HW server Project slot 4 (final version) due by end of school day. 
Jan 17-19: Demos!

Project Proposal: The purpose of this is to determine if your project idea is viable, and that your group can complete it. I can also assess if the project is too difficult/simple and offer suggestions to correct this. I strongly suggest coming up with at least one alternate project idea.  
-A paragraph and bullet points is sufficient. (per idea)

Regarding games: As a game enthusiast, it pains me to STRONGLY suggest you avoid games. I have found that students tend to focus on the wrong things when making games, or just implement them poorly.  
-Original games tend not to have a good goal for you to reach. Mashup games like pacman+spaceinvaders is an exception to this. 
-Clones of existing games often need modified controls to better suit the mouse+widgets mode of NetLogo. You cannot expect a game that requires keyboard input to work the way you want it to without a great deal of effort. 
-If you want to do a game, you ABSOLUTELY must have at least one alternative project idea.

1-10 of 63