1 / 6

Week 9 DO NOW QUESTIONS

Week 9 DO NOW QUESTIONS. Question: If the following procedure is executed after 1 turtle is created in the program, what shape is created on the NetLogo plane. to DrawShape ask turtle 0 [ repeat 18 [ forward 1 right 10

ozzie
Download Presentation

Week 9 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 9DO NOW QUESTIONS

  2. Question: If the following procedure is executed after 1 turtle is created in the program, what shape is created on the NetLogo plane. to DrawShape ask turtle 0 [ repeat 18 [ forward 1 right 10 set pcolor green ] ] end • A squiggly line • A straight line • A half circle • A complete circle

  3. Question: In a Netlogo world where approximately 1% of the patches are red and you have created 10 blue turtles, what does the following procedure do? to go ask patches [ if pcolor = red [ sprout 1 ] ] end • Create 1 blue turtles • Create a turtle on every red patch, each turtle is a random color • Create 10 additional blue turtles • Create a blue turtle on every red patch

  4. Question: In a NetLogo world where 10 turtles have been created, what does the wander procedure below do? to wander ask turtle 1 [ pendown set pen-size 5 while [pcolor = black] [ forward 1 set heading random 25 ] ] end • All the turtles wander around with their pens down • Turtle 1 wanders around drawing a line as it goes • Turtle 1 wanders around drawing a line as long as it is on a black patch • All the turtles walk around as long as they are on black patches

  5. Question: In a NetLogo program there is one turtle. 1% of the patches are green, 1 % of the patches are red and the rest are black. The following procedure, CalcultateSteps, is executed in the program. What does it do? to CalculateSteps ask turtles [ let NumberSteps 0 while [pcolor = green] [ forward 1 set NumberStepsNumbersteps + 1 print NumberSteps ] ] end • Calculates and prints the local variable NumberSteps which is the number of steps the turtle takes before it steps on a green patch. • Calculates and prints the local variable NumberSteps which is the number of steps the turtle takes while it steps on a green patch. • Calculates and prints the local variable NumberSteps which is the number of steps the turtle takes before it steps on a patch that is not black. • Calculates and prints the local variable NumberSteps which is the number of steps the turtle takes.

  6. Question: In the following piece of code, the programmer wants the turtles to get energy from eating grass by stepping on green patches and loose energy from walking around. After the turtles-own variable energy was created, the setup procedure created 10 turtles randomly distributed them and initialized their energy variable to 100. It also changes the color of some of the patches. Does this code do what the programmer intended? to go ask turtles [ right random 90 left random 90 forward 1 set energy energy - 1 if (pcolor = green) [set energy energy + 1] if (energy <= 0) [die] ] end • Perhaps, if there are green patches on the Netlogo surface. • Yes, the turtles eat grass when they step on a green patch and loose energy when they walk and die. • No, the turtles never die • No, the turtles cannot gain energy.

More Related