Exemple #1
0
        private Step(Step step, Tuple<IEnumerable<Cell>, int> pointsNCells)
        {
            height = step.height;
            width = step.width;
            commandIndex = step.commandIndex + 1;
            points = step.points + pointsNCells.Item2;

            Pieces = step.Pieces;
            CurrentPieceCells = Pieces[step.pieceIndex].Cells;
            UsedCells = pointsNCells.Item1.ToImmutableHashSet();
            Center = GetShift(CurrentPieceCells);
            RunningCells = CurrentPieceCells.Select(c => new Cell(c + Center)).ToImmutableHashSet();
            pieceIndex = (step.pieceIndex + 1) % step.Pieces.Count;
        }
Exemple #2
0
        private Step(Step step)
        {
            height = step.height;
            width = step.width;
            pieceIndex = step.pieceIndex;
            commandIndex = step.commandIndex + 1;
            points = step.points;

            Center = step.Center;
            Pieces = step.Pieces;
            CurrentPieceCells = step.CurrentPieceCells;
            UsedCells = step.UsedCells;
            RunningCells = step.RunningCells;
        }
Exemple #3
0
        private Step(Step step, IEnumerable<Cell> cells, IEnumerable<Cell> rotateCells, Cell newCenter)
        {
            height = step.height;
            width = step.width;
            pieceIndex = step.pieceIndex;
            commandIndex = step.commandIndex + 1;
            points = step.points;

            Center = newCenter;
            Pieces = step.Pieces;
            CurrentPieceCells = rotateCells.ToImmutableList();
            UsedCells = step.UsedCells;
            RunningCells = cells.ToImmutableHashSet();
        }
Exemple #4
0
 public void Run()
 {
     var step = new Step(field);
     commands.ToCharArray().Aggregate(step, (current, command) => current.NextStep(command));
 }