i'm new using NetLogo and I'm trying to learn it using the 'Hello World' model found on the net. I'm running NetLogo 5.2 on Mac OS X (Yosemite). When I try to set the turtles randomly, in this way
setxy random screen-size-x random screen-size-y
I get this error: Nothing named SCREEN-SIZE-X has been defined
screen-size-x appears in capitalization and so i get an error on this built-in function. Can anyone help me? Thank you
This is the NetLogo code I'm using:
globals [buttons] ; Global variables
to setup ; Initializes model for new run.
set-default-shape turtles "circle" ; Turtles are circles
clear-all ; Reset turtles and patches
set buttons 500 ; Set number of buttons to 500
create-turtles (buttons) ; Create "buttons" number of turtles
ask turtles [setup-turtles] ; Initialize each turtle
end
to setup-turtles ; Called for each turtle during setup
setxy random screen-size-x random screen-size-y ; Set our x,y randomly
end
I think screen-size-x
and screen-size-y
are NetLogo history. You can use max-pxcor
, max-pycor
and min-pxcor
, min-pycor
to get the world borders or world-width
and world-height
to get just the size.
To get a random position there are random-xcor
and random-ycor
.
to setup-turtles
setxy random-xcor random-ycor
end