NetLogo没有任何名为SCREEN-SIZE-X的定义

时间:2015-05-24 10:01:53

标签: netlogo screen-size

我是使用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

1 个答案:

答案 0 :(得分:2)

我认为screen-size-xscreen-size-y是NetLogo的历史记录。您可以使用max-pxcormax-pycormin-pxcormin-pycor来获取世界边界,或使用world-widthworld-height来获得大小。< / p>

要获得随机位置,有random-xcorrandom-ycor

to setup-turtles  
  setxy random-xcor random-ycor
end