/// <summary> /// 各セルのムーア近傍で生きているセルの数をリストアップします。 /// ただし、周りに1つも生きているセルが存在しないセルはリストに登録されません。 /// </summary> private void MakeNeighborList() { neighborlist.Clear(); foreach (var g in lifelist) { int[] delta = new int[] { -1, 0, 1 }; foreach (var i in delta) { foreach (var j in delta) { var cell = new CellOfLifeGame(g.X + i, g.Y + j); if (neighborlist.ContainsKey(cell)) { neighborlist[cell]++; } else { neighborlist.Add(cell, 1); } } } neighborlist[new CellOfLifeGame(g.X, g.Y)]--; } }
public void SetCell(CellOfLifeGame cell) { lifelist.Add(cell); }