### 2017-12-12 HWListResearch

posted Dec 12, 2017, 6:24 AM by Konstantinovich Samuel   [ updated Dec 12, 2017, 12:41 PM ]
 Goal1: SurveyDO NOT WRITE ON THE PAPER, Fill this out instead:https://goo.gl/forms/ISZnKCPNszdzeecH2Goal2: Lists, what are they good for? HW: Bring in a PRINTED paper copy tomorrow-Look through 2 different models in the NetLogo models library that utilize lists.     (They must be used for different things, color [ R G B] cannot be one of the things because we already discussed it)-For EACH model:    Explain how they are used (what they are for)    List and explain 2 things that you learned.Agent sets are similar to lists in the sense that they contain 0 or more agents. They are limited in some aspects:Lists can store an ordered set of items. (Agentsets have no order)The items can be agents or numerical values. (Agentsets are ONLY agents)The lists can be used to go through the items in a sequence, or until some event happens.Lets do some work with lists...While loops:while [ boolean-reporter] [     command block]e.g.while [ size >= 1][    stamp           set size size - .5    fd 1]    to showValues [ n]  let x 0  while [x < n]  [   show x   set x x + 1  ] endturtles-own [ name age]globals [ names ages]to setup  set names  [ "bob" "amy" "kenji" "keiko"  "lena" "hans"]  set ages   [ 22 24 20 25 19 22]endHow can we look at name/age pairs? Write a loop to print them together? Hint:(word 4 "," 5) turns into: "4,5"So you can show (word a "," b) to show two variables with a comma between them at the same time.You want to print in the format:bob,22amy,24...Solutions from class:turtles-own [ name age]globals [ names ages]to setup  ca  set names  [ "bob" "amy" "kenji" "keiko"  "lena" "hans"]  set ages   [ 22 24 20 25 19 22]  let n 0  while [ n < length names ]  [    show (word item n names ","  item n ages)    crt 1 [      set name item n names      set age item n ages      fd 3      set size 3    ]    set n n + 1  ]endto showValues [ n ]  let x 0  while [x < n]  [   show x   set x x + 1  ]endto listPrint [ L ]  let i 0  while [ i < length L ]  [   show item i L   set i i + 1  ]endto listPrint2 [ L ]  while [ length L > 0]  [   show first L   show L   show " "   set L but-first L  ]endQUIZ IDEAS for moving a patch around the screen:ask patches with [pcolor = white][  ;   include the top, except for the rightmost patch  if pycor = max-pycor and pxcor < max-pxcor  [ set pcolor black    ask patch-at 1 0 [ set pcolor white]  ]  ;repeat for with the other 3 sides...]