Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
 public FixedGrid(FixedGrid <T> other) : this(other.Data.Length, other.IncludeCorners)
 {
     CopyFrom(other);
 }
Exemplo n.º 3
0
 public Board(string[] data)
 {
     Grid = data.Select(s => s.Spaced().Ints()).ToFixedGrid(5, 5);
 }