Fix Cell Population

This commit is contained in:
Marty Oehme 2018-07-06 15:00:45 +02:00
parent b16d108e70
commit c2d46c6e38
2 changed files with 9 additions and 7 deletions

View file

@ -18,6 +18,6 @@ class Cell {
if (rule.evaluate(neighbors) == true) newState = true;
});
}
state = newState;
this.state = newState;
}
}

View file

@ -13,6 +13,8 @@ class Grid {
map.addAll(_buildGrid(w, h));
map[5][5].state = true;
map[5][6].state = true;
map[5][7].state = true;
print("Grid creation finished");
}
@ -21,11 +23,11 @@ class Grid {
List<List<Cell>> grid = new List(h);
Rule threeTrue = new Rule((int n) {
if(n==3) return true;
else return false;
return false;
});
Rule twoTrue = new Rule((int n) {
if(n==2) return true;
else return false;
return false;
});
for (int y = 0; y < h; y++) {
@ -35,9 +37,9 @@ class Grid {
Cell cell = new Cell();
cell.surviveRules.add(twoTrue);
cell.surviveRules.add(threeTrue);
cell.birthRules.add(twoTrue);
cell.birthRules.add(threeTrue);
grid[y][x] = new Cell();
grid[y][x] = cell;
}
}
return grid;