Ok

its a bit embarrassing. I have no professional training and I coded this by my self so probably there are many ways to make it better.

basically I created an array of points and an array of colors. according to the evaluation of the neighbourhood the array of colors stored one color or other. In this case dead is gray and alive is red

What I am trying to do is, if the point is alive, depending on the size of alive neighbours in the neighbourhood, modify the shade of red. For that I am trying to just change the R value of each color in the array.

private void RunScript(Rectangle3d iArea, int cols, int rows, int seed, bool iReset, ref object A, ref object B, ref object C)

{

```
Point3d[,] initialGrid = new Point3d[cols, rows];
Color [,] initialColors = new Color[cols, rows];
int [,] initialStates = new int[cols, rows];
int [,] myNeighbourhood = new int[cols, rows];
Color red = Color.FromArgb(255, 0, 0);
Color dead = Color.FromArgb(50, 50, 50);
Random myRandomGenerator = new Random(seed);
double areaHeight = iArea.Height;
double areaWidth = iArea.Width;
for(int i = 0;i < cols;i++){
for(int j = 0;j < rows;j++){
double pixelSizeC = areaWidth / cols;
double pixelSizeR = areaHeight / rows;
initialGrid[i, j] = new Point3d (i * pixelSizeC, j * pixelSizeR, 0);
initialColors[i, j] = dead;
initialStates[i, j] = 0;
double state = myRandomGenerator.NextDouble();
if (state < 0.50){
initialColors[i, j] = red;
}
if (initialColors[i, j] != dead){
initialStates[i, j] = 1;
}
}
}
if(iReset){
grid = initialGrid;
colors = initialColors;
myState = initialStates;
NeighboursCount = myNeighbourhood;
}
int [,] futureState = new int[cols, rows];
for(int i = 0;i < cols;i++){
for(int j = 0;j < rows;j++){
int count = 0;
if( myState[(i + cols - 1) % cols, ( j + rows + 1) % rows] != 0)
count++;
if( myState[(i + cols) % cols, ( j + rows + 1) % rows] != 0)
count++;
if( myState[(i + cols + 1) % cols, ( j + rows + 1) % rows] != 0)
count++;
if( myState[(i + cols + 1) % cols, ( j + rows) % rows] == 1)
count++;
if( myState[(i + cols + 1) % cols, ( j + rows - 1) % rows] != 0)
count++;
if( myState[(i + cols) % cols, ( j + rows - 1) % rows] != 0)
count++;
if( myState[(i + cols - 1) % cols, ( j + rows - 1) % rows] != 0)
count++;
if( myState[(i + cols - 1) % cols, ( j + rows) % rows] != 0)
count++;
NeighboursCount[i, j] = count;
if(myState[i, j] == 1 && count < 2){
// dead;
futureState[i, j] = 0;
}
if (myState[i, j] == 1 && count <= 3 && count >= 2){
// alive;
futureState[i, j] = 1;
}
if (myState[i, j] == 1 && count > 3){
// dead;
futureState[i, j] = 0;
}
if (myState[i, j] == 0 && count == 3){
//alive;
futureState[i, j] = 1;
}
}
}
myState = futureState;
for(int i = 0;i < cols;i++){
for(int j = 0;j < rows;j++){
if(myState[i, j] == 0){
colors[i, j] = dead;
}
if(myState[i, j] == 1 && NeighboursCount[i, j] == 1 ){
colors[i, j].R = 100;
}
if(myState[i, j] == 1 && NeighboursCount[i, j] == 2 ){
colors[i, j].R = 200;
}
if(myState[i, j] == 1 && NeighboursCount[i, j] > 2 ){
colors[i, j].R = 255;
}
}
}
A = grid;
B = colors;
C = myState;
```

}

//

Point3d[,] grid;

Color[,] colors;

int [,] myState;

int [,] NeighboursCount;

Here is the file

CA - color variations.gh (20.2 KB)