public int Step(FixedGrid <int> grid) { var flashes = 0; var inc = new Queue <Pos>(grid.Bounds); while (inc.Count > 0) { var next = inc.Dequeue(); if (++grid[next] == 10) { flashes++; grid.GetNeighbors(next).ForEach(inc.Enqueue); } } grid.WhereValue(i => i > 9).Keys().ForEach(pos => grid[pos] = 0); return(flashes); }
public FixedGrid(FixedGrid <T> other) : this(other.Data.Length, other.IncludeCorners) { CopyFrom(other); }
public Board(string[] data) { Grid = data.Select(s => s.Spaced().Ints()).ToFixedGrid(5, 5); }