# How do you set a certain amount of patches a certain color?

+10 votes

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

asked
+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 (8 points)
selected
+7 votes

try if this works

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

and then repeat maybe

answered by (8 points)
edited
+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 (2.3k points)
edited
+1

that worked for me.