Exemplo n.º 1
0
        /// <summary>
        /// Builds the yellow cross for OLL.
        /// </summary>
        private void BuildYellowCross()
        {
            foreach (RubiksColor col in SideColors)
            {
                // Sets the view.
                ChangeView(new CubeView(col, FINAL_COLOR));

                // Gets the configuration.
                LastLayerConfiguration config = new LastLayerConfiguration(_cube.GetFaceCubies(Face.Up));

                // Uses the correct algorithm if any match is found.
                if (config.Matches(OllCases.YellowCenter))
                {
                    // If the configuration matches the yellow center case, another algorithm will be needed.
                    AddMoveList(Algorithms.OLLCross1);
                    BuildYellowCross();
                }
                else if (config.Matches(OllCases.YellowL))
                {
                    AddMoveList(Algorithms.OLLCross2);
                }
                else if (config.Matches(OllCases.YellowLine))
                {
                    AddMoveList(Algorithms.OLLCross1);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the OLL phase.
        /// </summary>
        private void OLL()
        {
            // The first thing to do is to build a yellow cross.
            BuildYellowCross();

            // Gets the configuration of the last layer.
            LastLayerConfiguration conf = new LastLayerConfiguration(_cube.GetFaceCubies(Face.Up));

            // Keeps on changing the view until OLL is complete.
            for (int c = 0; !conf.Matches(OllCases.OLLComplete); c++)
            {
                // Sets the view.
                ChangeView(new CubeView(SideColors[c], FINAL_COLOR));

                // Gets the configuration before the algorithms.
                conf = new LastLayerConfiguration(_cube.GetFaceCubies(Face.Up));

                // If the configuration matches any of the situations, the proper algorithm will be used.
                if (conf.Matches(OllCases.OLLSituation1))
                {
                    AddMoveList(Algorithms.OLLSituation1);
                }
                else if (conf.Matches(OllCases.OLLSituation2))
                {
                    AddMoveList(Algorithms.OLLSituation2);
                }
                else if (conf.Matches(OllCases.OLLSituation3))
                {
                    AddMoveList(Algorithms.OLLSituation3);
                }
                else if (conf.Matches(OllCases.OLLSituation4))
                {
                    AddMoveList(Algorithms.OLLSituation4);
                }
                else if (conf.Matches(OllCases.OLLSituation5))
                {
                    AddMoveList(Algorithms.OLLSituation5);
                }
                else if (conf.Matches(OllCases.OLLSituation6))
                {
                    AddMoveList(Algorithms.OLLSituation6);
                }
                else if (conf.Matches(OllCases.OLLSituation7))
                {
                    AddMoveList(Algorithms.OLLSituation7);
                }

                // Gets the configuration after the algorithms.
                conf = new LastLayerConfiguration(_cube.GetFaceCubies(Face.Up));
            }
        }
        /// <summary>
        /// Checks if this configuration matches another one.
        /// </summary>
        /// <param name="conf">The other configuration.</param>
        /// <returns>True if the two configurations match.</returns>
        public bool Matches(LastLayerConfiguration conf)
        {
            for (int x = 0; x < _face.GetLength(0); x++)
            {
                for (int y = 0; y < _face.GetLength(1); y++)
                {
                    if (this[x, y] == RubiksColor.NonYellow || conf[x, y] == RubiksColor.NonYellow)
                    {
                        if (this[x, y] == RubiksColor.Yellow || conf[x, y] == RubiksColor.Yellow)
                        {
                            return(false);
                        }
                    }

                    else if (this[x, y] != RubiksColor.Any && conf[x, y] != RubiksColor.Any && this[x, y] != conf[x, y])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }