Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+10 votes

For example, like set the top ten layers of patches blue to make the sky?

asked in CSC 150 January201920 by (1 point)
+2

You can use an "ifelse" or "if" statement. For example is used

;ground
ask patches [if pzcor = -16 [set pcolor 36]]
;river
ask patches [if pxcor > 5 and pxcor < 12 and pzcor = -16 [set pcolor blue]]

to make the ground and a river!

3 Answers

+7 votes
 
Best answer

You can use the < and > signs and write the intervals that you want. For example

if pzcor <= -13 [ set pcolor brown - 3 + random 3]

Or

  if pzcor <= 13 and pzcor >= 10 [ set pcolor brown - 3 + random 3] 
answered by (1 point)
selected by
+7 votes

try if this works

ask patches with [pzcor = -16 ]
 [
    set pcolor blue + random 3
  ]

and then repeat maybe

answered by (1 point)
edited by
+4 votes

If you are looking to change the color of some patches, you also use:

if random 100 = 0 [
set pcolor list [0 0 255 30]
]

This is for a more translucent kind of look.

answered by (1 point)
edited by
+1

that worked for me.

...