我正在尝试将我的模型更新到 NL 6,因为自动更新失败(主要是由于匿名过程的语法)。我的模型使用 rnd 扩展,该扩展现在显然与 NetLogo 捆绑在一起,但来自 the manual 的示例仍然提到这一点:
extensions[rnd]
to go
let pairs [ [ "A" 0.2 ] [ "B" 0.8 ] ]
repeat 25 [
; report the first item of the pair selected using
; the second item (i.e., `last ?`) as the weight
type first rnd:weighted-one-of-list pairs [ last ? ]
]
end
这会导致错误,因为“没有定义名为 ? 的内容”。我已经能够转换其他内容,例如 foreach 和 n 值,但我正在努力将此示例转换为 NetLogo 6 所需的新符号。有人可以帮忙吗?
最佳答案
在转换 rnd
扩展手册以将其与 NetLogo 捆绑时,我们错过了一些情况。这将在 NetLogo 6.0.1 中修复。同时,您可以引用GitHub上最新版本的手册:
https://github.com/NetLogo/Rnd-Extension/blob/hexy/README.md
在您的具体情况下,NetLogo 6 语法将是:
rnd:weighted-one-of-list pairs [ [p] -> last p ]
关于NetLogo 6 和 rnd 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41680066/