NetLogo:在 "Settings" 之外的代码中通过滑块设置世界大小?

NetLogo: setup world size by slider in code not in "Settings"?

我想在 NetLogo GUI 中将我的 world size(居中,正方形)实现为 slider - 在代码中,而不是通过"settings" 个选项。 但是我不知道在我的代码中如何以及在哪里编写它?我知道我可以在 BehaviorSpace 中使用 world-width 和 world-height 作为记者,但我想以交互方式更改 world 的参数。

我想我可以简单地将它写入 setup 过程:

to setup
  clear-all
  reset-ticks
  set world-width world_size
  set world-height world-size
  setup-turtles
  setup-patches
end

或写在

to setup-patches
  ask patches [
    set world-width world_size
    set world-width world_size
  ]
end

在两种方法中我都遇到了错误:This isn't something you can use "set" on.

我确定这是一个微不足道的问题,但我找不到我的答案..谢谢!!

看看字典中的 resize-world 原语

最终代码 - 使用滑块确定世界大小,感谢@JenB 和@SethTisue:

to setup
  clear-all
  reset-ticks

  ; use slider "world-size" in GUI
  resize-world (world_size * -1)  world_size (world_size * -1) world_size 
  ; resize-world -15 15 -15 15 ;   example without slider
  setup-patches
end