我想用NETLOGO模拟沿河的水流。因此,我确实有许多相互链接的水节点。每个水节点的变量为“ amount_water”。每次刻度时,变量“ amount_water”都应传递到下一个水节点。在每个节点,用水者(各种媒介)可以与水流相互作用并提取一些水,这将改变变量“ amount_water”。但现在我只想向您展示模拟的河流流量,而没有用水户。
如果您的模型世界具有min-pycor -6和max-pycor 6:
breed [waternodes waternode]
waternodes-own
[
amount_water
]
to setup
clear-all
reset-ticks
; create the waternodes
create-waternodes 13 [setxy 0 (who - 6) set shape "dot" set color blue]
ask waternodes
[
let neighborbelow waternodes-on neighbors4 with [pycor < [ycor] of myself]
create-links-to waternodes-on neighborbelow
]
end
to go
move-water
update-inflow
tick
end
to move-water
ask waternodes
[
ask out-link-neighbors [set amount_water [amount_water] of myself]
]
end
to update-inflow
ask waternode 12 [set amount_water ticks]
end
(在我的模型中,流入的当然不是滴答声的数目,但它是从csv文件读取的)
我的问题:使用此代码,水量无法从一个节点连续传递到另一个节点(而且我也不知道为什么!)?
通常,我不确定此网络是否是代表流的最佳想法。您能想到其他解决方案吗?
非常感谢
答案 0 :(得分:1)
到目前为止,我已经解决了问题。看来当我像这样在移动水中调用水节点时
to move-water
ask waternodes
[
ask out-link-neighbors [set amount_water [amount_water] of myself]
]
end
,并不总是按0到11的顺序调用水节点。
因此我将代码更改为
to move-water
(foreach sort-on [who] waternodes
[the-turtle -> ask the-turtle [ask out-link-neighbors [set amount_water [amount_water] of myself]]])
end
现在它正在工作!