|
@@ -1,26 +0,0 @@
|
|
|
-
|
|
|
-
|
|
|
-export default function processCell(neighbourhood) {
|
|
|
- const livingNeighbours = neighbourhood.reduce(function countRows(acc, row, ind) {
|
|
|
- return acc + row.reduce((s, c, i) => (!(ind === 1 && i === 1) ? s+c : s));
|
|
|
- }, 0);
|
|
|
-
|
|
|
- if( neighbourhood[1][1] ) {
|
|
|
- if( livingNeighbours < 2 ) {
|
|
|
- neighbourhood[1][1] = 0;
|
|
|
- }
|
|
|
- else if( livingNeighbours > 3 ) {
|
|
|
- neighbourhood[1][1] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- if( livingNeighbours === 3 ) {
|
|
|
- neighbourhood[1][1] = 1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return neighbourhood;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|