1 / 6

Week DO NOW QUESTIONS

Week DO NOW QUESTIONS.

avidan
Download Presentation

Week DO NOW QUESTIONS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week DO NOW QUESTIONS

  2. The programmer is trying to have the turtles stop moving around once there are no more are red turtles. The program creates 100 turtles of random colors and randomly distributes green patches. Every time the turtles land on a green patch, the color of the turtle is turned green too! The following code has an error What’s wrong with it? while [count turtles with [color = red] > 0] ask turtles [fd 1 ] • The reporter, count turtles with [color = red] > 0, does not count the number of red turtles. • The while command is the wrong command to use, you should use the repeat comment. • The ask turtles command is incorrect because you want the observer to perform the commands • You are missing a pair of square brackets, starting before the ask command and ending after the last square bracket because it is necessary to contain the commands to be performed by while the reporter is true in square brackets.

  3. You are trying to understand a NetLogo program written by another programmer. You come across across the following line of code set thoseones turtles with [(xcor > 0) and (ycor > 0) and (pcolor = green)] What does it do? • It sets the variable mylist to the number of turtles one green patches • It assigns the turtles in the upper right quadrant on green patches to the agentsetthoseones • It creates an agentset, thoseones, of green turtles in the upper right quandrant. • It puts all the turtles on green patches

  4. You have a model with dogs and cats. The dogs chase the cats but do not like to share space with another dog. You want to prevent the dogs from moving onto patches that contain other dogs. Here is the code that you wrote ask dogs [ if not any? cats-on patch-ahead 1 [ fd 1 ] ] What is wrong with it? • There is no patch-ahead command • The word not should be in front of the word if • cats-on should be changes to dogs-on • any? is not a NetLogo command

  5. You have a list, mylist, that contains 9 numbers (even number from 1 – 20). You want to prepend 0 to the list. What is the command and the resulting list • prepend mylist 0 mylist ;; [ 0 2 4 6 8 10 12 14 16 18 20] • fputmylist 0 mylist ;; [ 0 2 4 6 8 10 12 14 16 18 20] • lputmylist 0 mylist ;; [ 2 4 6 8 10 12 14 16 18 20 0] • prepend mylist 0 mylist ;; [ 2 4 6 8 10 12 14 16 18 20 0]

  6. You have created containing the numbers 10, 25, 1002 and 4. The following command is given in your code after the list is created show n-of 4 mylist • the numbers [10 25 1002 4] are printed in the command center • the number 4 is printed in the command center • one of the 4 numbers is printed in the command center • nothing is printed in the command center

More Related