/// <summary> /// Gibt den Farbunterschied eines weißen Kantensteins zurück /// </summary> /// <param name="edge">Der Kantenstein, dessen Farbunterschied bestimmt werden soll</param> /// <returns></returns> protected int GetDelta(EdgeStone edge) { CubeColor edgeColor = edge.GetColors().First(c => c != WHITE); CubeFace face = edge.GetColorPosition(c => c != WHITE).Face; return(SolvingUtility.GetDelta(edgeColor, face, UP)); }
/// <summary> /// Gibt die zweite Farbe eines weißen Kantensteins zurück /// </summary> /// <param name="edge">Der Kantenstein, dessen zwiete Farbe bestimmt werden soll</param> /// <returns></returns> protected CubeColor GetSecondColor(EdgeStone edge) { IEnumerable <CubeColor> colors = edge.GetColors(); if (!colors.Contains(WHITE)) { throw new ArgumentException("Der Kantenstein muss die Farbe Weiß besitzen"); } return(colors.First(c => c != WHITE)); }
/// <summary> /// Gibt die Anzahl der Züge zurück, die benötigt wird, um den Kantenstein in die richtige Position zu bringen. /// </summary> /// <param name="edge">Der Kantenstein, der in die richtige Position gebracht werden soll</param> /// <returns></returns> protected int GetStoneRating(EdgeStone edge) { // on white face and same delta as pivot stone if (IsEdgeRight(edge)) { return(0); } Position whitePosition = edge.GetColorPosition(WHITE); int edgeDelta; // on white face and not same delta as pivot stone or on yellow face if (whitePosition.Face == UP || whitePosition.Face == DOWN) { // get delta of edge if (whitePosition.Face == DOWN) { edgeDelta = SolvingUtility.GetDelta( GetSecondColor(edge), // second color edge.GetColorPosition(c => c != WHITE).Face, // second color face color UP); // face to rotate } else { edgeDelta = GetDelta(edge); } // return 2 + moves white face count int sortingMoves = Math.Abs(SolvingUtility.NormalizeCount(edgeDelta - WhiteFaceOrientation, -1)); return(2 + sortingMoves); } // on middle layer else { switch (whitePosition.Tile) { // false orientated on white face case 1: edgeDelta = SolvingUtility.GetDelta( GetSecondColor(edge), //second color edge.GetColorPosition(WHITE).Face, // middle layer face with white side of edge UP); //face to rotate int edgePivotDelta = SolvingUtility.NormalizeCount(edgeDelta - WhiteFaceOrientation); // return number of moves return((edgePivotDelta % 2) * -1 + 3); // false orientated on yellow face case 7: // this position can always solved in 3 moves return(3); // on middle layer default: edgeDelta = SolvingUtility.GetDelta( edge.GetColors().First(c => c != WHITE), // second color edge.GetColorPosition(c => c != WHITE).Face, // second color face color UP); // face to rotate int sortingMoves = Math.Abs(SolvingUtility.NormalizeCount(edgeDelta - WhiteFaceOrientation, -1)); return(1 + sortingMoves); } } }