2D Array Search
Posted on 1997-07-08
Working on what to everyone else is a simple program but to me is proving quite difficult. Program simulates birth and death within a two dimensional array.
Specifically, after the user specifies that life exists in say seven elements, successive generations are displayed using these two rules:
1) an organism in a cell survives to the next generation if exactly 2 or 3 of its neighbors are living, otherwise it dies
2) an organism is born into an unoccupied cell if exactly 3 of its neighbors are unoccupied.
Obviously I'm a student and I don't even know where to begin writing what is probably a series of loops to search for values in the six surrounding elements.
Would someone please show me what this code would look like and explain the why of it?