private static int GetSliceScale(Axis axis, Piece piece) { return axis == Axis.FrontBack ? piece.Size.Length : axis == Axis.TopBottom ? piece.Size.Height : piece.Size.Width; }
private void AddSlice(Axis axis, Piece piece) { if (piece.HasColorsOnSides(new[] { edges[(int)axis][0] })) slices[(int)axis].Insert(0, GetSliceScale(axis, piece)); else if (piece.HasNoColorsOnSides(new[] { edges[(int)axis][1] })) { if (slices[(int)axis].Count == 0) slices[(int)axis].Add(GetSliceScale(axis, piece)); else slices[(int)axis].Insert(slices[(int)axis].Count - (isSlicingFinished[(int)axis] ? 1 : 0), GetSliceScale(axis, piece)); } else { slices[(int)axis].Add(GetSliceScale(axis, piece)); isSlicingFinished[(int)axis] = true; } }
public void AddInitialData(int length, int height, int width, string coloring) { basePiece = new Piece(new Size { Length = length, Height = height, Width = width }, coloring); }
public static Piece GetDefiningPiece(int length, int height, int width, string coloring, Piece basePiece) { Piece newPiece = new Piece(new Size { Length = length, Height = height, Width = width }, coloring); while (!newPiece.MatchBasePiece(basePiece)) newPiece.CommitNextRotation(); return newPiece; }
public static string FormColoring(Piece basePiece, params bool[] coloring) { return new String(Enumerable.Range(0, 6).Select(e => coloring[e] ? basePiece.Coloring[e] : '.').ToArray()); }
public static bool MatchBasePiece(this Piece piece, Piece basePiece) { return Enumerable.Range(0, 6).All(e => piece.Coloring[(int)piece.Rotation[e]] == '.' || piece.Coloring[(int)piece.Rotation[e]] == basePiece.Coloring[e]); }
public bool Equals(Piece other) { return Identity.Equals(other.Identity); }