我是使用NetLogo的新手,我正在尝试使用网上找到的“Hello World”模型来学习它。我在Mac OS X(Yosemite)上运行NetLogo 5.2。当我尝试以这种方式随机设置海龟时
setxy random screen-size-x random screen-size-y
我收到此错误:未定义任何名为SCREEN-SIZE-X的内容
screen-size-x以大写形式出现,因此我在此内置函数中出错。谁能帮我?谢谢
这是我正在使用的NetLogo代码:
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
答案 0 :(得分:2)
我认为screen-size-x
和screen-size-y
是NetLogo的历史记录。您可以使用max-pxcor
,max-pycor
和min-pxcor
,min-pycor
来获取世界边界,或使用world-width
和world-height
来获得大小。< / p>
要获得随机位置,有random-xcor
和random-ycor
。
to setup-turtles
setxy random-xcor random-ycor
end