[Question Answered] Need to remove it.

# How to generate forest

Asked by Community At## 2 Answers

0

On

You're implementing a Cellular Automaton, and to simulate this you will need to create a copy of the array for your work. The basic algorithm would work as follows:

```
new_state = state.copy()
for i in range(height):
for j in range(width):
new_state[i,j] = calculate_new_cell(state, i, j)
state = new_state
```

(The `calculate_new_cell(state, i, j)`

function is dependent on the rules of the cellular automaton.)

Not to solve the entire problem for you and take away all the fun, but I believe the missing piece is

`np.where`

:This function outputs x,y coordinates in the matrix that you can use to perform tests on, and take actions with in adjacent cells (coordinates).

You can combine these coordinate pairs like so to iterate over them:

The state management as explained in this other answer on your question will also be required.