예제 #1
0
 public _4DGridPosition(X_Value x, Y_Value y, Z_Value z, W_Value w)
 {
     this.X = x;
     this.Y = y;
     this.Z = z;
     this.W = w;
 }
예제 #2
0
파일: Solution.cs 프로젝트: genveir/Advent
        public void SetGrid(int dimensions)
        {
            grid = new SwappingGrid();

            for (int n = 0; n < 2; n++)
            {
                var builder = new InfiniteAdjacencyGridBuilder <int, _4DGridPosition>();
                if (dimensions > 3)
                {
                    builder.AddLayer(igp => igp.W, (igp, val) => igp.W = val);
                }
                if (dimensions > 2)
                {
                    builder.AddLayer(igp => igp.Z, (igp, val) => igp.Z = val);
                }
                builder.AddLayer(igp => igp.Y, (igp, val) => igp.Y = val);
                builder.AddLayer(igp => igp.X, (igp, val) => igp.X = val);
                grid.Current = builder.Complete();

                grid.Swap();
            }

            var wCoord = W_Value.Get(0);
            var zCoord = Z_Value.Get(0);

            for (int y = 0; y < lines.Length; y++)
            {
                var yCoord = Y_Value.Get(y);

                for (int x = 0; x < lines[y].Length; x++)
                {
                    var xCoord = X_Value.Get(x);

                    var pos = new _4DGridPosition(xCoord, yCoord, zCoord, wCoord);

                    int val = 0;
                    if (lines[y][x] == '#')
                    {
                        grid.Front.Add(pos);
                        val = 10000;
                    }

                    grid.Current.Set(pos, val);
                }
            }
            grid.Front.Swap();

            ofInterest = new HashSet <_4DGridPosition>();
        }