Skip to main content

7.6) Artificial Landscape Submodel


Add the following code to the bottom of your code as a submodel:

to set-artificial-landscape
   let elev1 100 - distancexy 30 70
   let elev2 70 - distancexy 80 40
   ifelse elev1 > elev2
      [set elevation elev1]
      [set elevation elev2]
   set pcolor scale-color green elevation 0 100
end

The idea is that there are two conical hills, with peaks at locations (x,y- coordinates) 30,70 and 90,40. The first hill has an elevation of 100 units (let’s assume these elevations are in meters) and the second an elevation of 70 meters.

First, we calculate two elevations (elev1 and elev2) by assuming the patch’s elevation decreases by one meter for every unit of horizontal distance between the patch and the hill’s peak (remind yourself what the primitive distancexy does by putting your cursor over it and hitting the F1 key).

Then, for each patch we assume the elevation is the greater of two potential elevations, elev1 and elev2: using the ifelse primitive, each patch’s elevation is set to the higher of the two elevations. Finally, patch elevation is displayed on the View by setting patch color pcolor to a shade of the color green that is shaded by patch elevation over the range 0 and 100 (look up the extremely useful primitive scale-color).