我需要一些帮助来设置一个特殊的地形。我有一个200x200个补丁的世界,每个补丁有2个像素的大小。我想做的是从原点开始造一座小山,然后将高度均匀地分布到世界的边缘。
原点的最高海拔高度约为999,边缘周围的补丁的海拔高度接近于0。从世界的边缘,海拔应该不断增加,直到它到达原点。然而,我似乎不能让小山延伸到世界的边缘-在中间有一个小颠簸,而世界的其余部分是完全平坦的。
有没有人可以帮助我设置地形,并解释如何让高度适当地扩散?
以下是我到目前为止拥有的代码:
patches-own [altitude]
to setup
clear-all
ask patch 0 0 [set altitude 1.0]
repeat 100 [diffuse altitude 0.25] ;; this needs to be changed?
scale-patches
color-patches
end
to scale-patches
let low [altitude] of min-one-of patches [altitude] ;; altitude of the lowest patch
let high [altitude] of max-one-of patches [altitude] ;; altitude of the highest patch
let range high - low ; difference from lowest to highest
ask patches [
set altitude altitude - low ; Shift every patch down so lowest altitude is 0
set altitude altitude * 999.0 / range ; Scale every patch so that the lowest is 0 and highest is 999
]
end
to color-patches
ask patches [set pcolor scale-color green altitude 0 1000]
end发布于 2011-03-11 04:51:16
替换这两行如何:
ask patch 0 0 [set altitude 1.0]
repeat 100 [diffuse altitude 0.25] ;; this needs to be changed?有了这个:
ask patches [ set altitude world-width - distance patch 0 0 ]它不使用扩散,但也许它解决了你的问题?
https://stackoverflow.com/questions/5221799
复制相似问题