观察者上下文中补丁的 NetLogo 映射变量
NetLogo map variable of patch in observer context
我正在尝试按照与生成它们的列表相同的顺序映射一个补丁变量(参见下面的代码)。但是,我得到一个 "error while observer running SET test2",因为它在观察者上下文中不能是 运行。我不明白这一点,因为这似乎是一个简单的过程。
globals [test test2]
patches-own [wealth]
to setup
ca
ask patches
[set wealth random 100]
end
to go
set test [self] of patches
show test
set test2 map [wealth] test
show test2
end
您可以将 set test2 map [wealth] test
更改为 set test2 map [x -> [wealth] of x] test
。但是,每当您使用代理列表而不是代理集时,您应该问这是否真的有必要。
我正在尝试按照与生成它们的列表相同的顺序映射一个补丁变量(参见下面的代码)。但是,我得到一个 "error while observer running SET test2",因为它在观察者上下文中不能是 运行。我不明白这一点,因为这似乎是一个简单的过程。
globals [test test2]
patches-own [wealth]
to setup
ca
ask patches
[set wealth random 100]
end
to go
set test [self] of patches
show test
set test2 map [wealth] test
show test2
end
您可以将 set test2 map [wealth] test
更改为 set test2 map [x -> [wealth] of x] test
。但是,每当您使用代理列表而不是代理集时,您应该问这是否真的有必要。