I want to create a simulator with for loops to simulate this scenario.
For example, I have a 20x20 matrix with 1s or 0s, and I want to find how many 1s are there around every 1 and 0. If there is 2 or 3 1s around 1, then this '1' will be kept, otherwise, it will be turned into a 0 in the next step. As for 0s, if there is exact three 1s around it, it will be turned to a 1, otherwise it will still be 0.
I tried to use a filter to make this happen, but failed.