2

我需要一些帮助来设置特定的地形。我有一个 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
4

1 回答 1

2

如何替换这两行:

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 ]

它不使用扩散,但也许它可以解决您的问题?

于 2011-03-10T20:51:15.797 回答