ask turtles [set energy 10]
will fail UNLESS:
An agentset is called first.
The programmer has defined “turtles” as a breed.
***”Energy” is defined as a turtles-own variable.
10 is not larger than the maximum value defined for energy.
The programmer does not call please before the ask command.
7) In Netlogo, the code:
setxy random-xcor random-ycor
can only be used in which of the following circumstances?
****Inside an “ask turtle“ or “ask“ breed block.
After “reset-ticks“
Inside a “go” procedure.
Inside a “setup” procedure.
Inside an “ask-patches“ block.
8) Why does the following code fail?
to grow ;;called by button on the interface.
show count patches
show "Growing"
set color red
ask turtles
[
repeat 3
[
forward 1
right 20
]
]
end
Because “Growing” has not been defined.
Because “Repeat” is not a command.
*** Because “set color” cannot be outside of an “ask turtles” block.
Because “Repeat” cannot be inside an “ask turtles” block.
Because “Count” can only be used with an agentset.
9) What is the final value of n in the NetLogo code below:
let n 10
if (n > 5)
[ set n (n - 2)
]
set pen-size n
-2
***8
10
5
2
10) In a NetLogo program, two turtles have been created when the code segment below is reached. What values of n are displayed in the NetLogo command center?
ask turtles
[ let n 10
while [n > 2]
[ forward n
right 15
set n (n - 1)
]
print n
]
a) 10 10
b) ****2 2
c) 3 3
d) 1 1
e) 2 1
Share with your friends: |