meerkat
meerkat

Reputation: 94

Netlogo terrain creation and diffusion

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

Upvotes: 2

Views: 554

Answers (1)

Seth Tisue
Seth Tisue

Reputation: 30453

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?

Upvotes: 2

Related Questions