Netlogo 地形创建和传播

发布于 2024-10-20 17:01:22 字数 1078 浏览 8 评论 0原文

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

I need some help setting up a particular terrain. I have a world that is 200x200 patches and each patch has a size of 2 pixels. What I am trying to do is to make a hill starting at the origin, and then have the altitude evenly spread out to the edges of the world.

The origin would have around the highest altitude: 999, and patches around the edges would have the altitudes closes to 0. From the edges of the world, the altitude should constantly increase, until it gets to the origin However, I can't seem to get the hill to extend out to the edges of the world - there is a little bump in the middle, and the rest of the world is completely flat.

Can anyone help on setting up the terrain and explain how I can get the altitude to diffuse properly?

Here's the code I have so far:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海之角 2024-10-27 17:01:22

如何将这两行替换

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 ]

:它不使用扩散,但也许它无论如何都能解决您的问题?

How about replacing these two lines:

ask patch 0 0 [set altitude 1.0]
repeat 100 [diffuse altitude 0.25]  ;; this needs to be changed?

with this:

ask patches [ set altitude world-width - distance patch 0 0 ]

It doesn't use diffusion, but maybe it solves your problem anyway?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文