Like a checkerboard?

+7 votes

Best answer

Indeed it is! The easiest way to do it is to check whether the x & y coordinates sum to an even or odd number. We can do that by checking whether the remainder is 0 or 1 when you divide that number by 2. In NetLogo, you can find the remainder after division using the MOD operation.

In NetLogo 2D, you would use:

```
ask patches [
if (pxcor + pycor) mod 2 = 0 [
set pcolor blue
]
if (pxcor + pycor) mod 2 = 1 [
set pcolor red
]
]
```

In NetLogo 3D, you would do the same thing, but you only want to ask ONE layer of patches to do it, so just change your initial ASK to only have one z-coordinate layer.

```
ask patches with [ pzcor = -16 ] [
if (pxcor + pycor) mod 2 = 0 [
set pcolor blue
]
if (pxcor + pycor) mod 2 = 1 [
set pcolor red
]
]
```