Example #1
0
        private void init(string file = null)
        {
            this.mainViewport.Children.Remove(c);
            this.mainViewport.Children.Remove(touchFaces);

            rotations.Children.Clear();
            doneMoves.Clear();

            solveMenu.IsEnabled = false;

            if (file != null)
            {
                c = new RubikCube(IO.read(file, out doneMoves), size, new Point3D(-len / 2, -len / 2, -len / 2), TimeSpan.FromMilliseconds(370), edge_len, space);
            }
            else
            {
                c = new RubikCube(size, new Point3D(-len / 2, -len / 2, -len / 2), TimeSpan.FromMilliseconds(370), edge_len, space);
            }

            c.Transform = rotations;

            touchFaces = Helpers.createTouchFaces(len, size, rotations,
                                                  new DiffuseMaterial(new SolidColorBrush(Colors.Transparent)));

            this.mainViewport.Children.Add(c);
            this.mainViewport.Children.Add(touchFaces);

            if (!enableAnimations.IsChecked)
            {
                c.animationDuration = TimeSpan.FromMilliseconds(1);
            }

            if (file == null)
            {
                scramble(25);
            }

            //gameOver = false;
            saveMenu.IsEnabled  = true;
            solveMenu.IsEnabled = true;
        }
Example #2
0
        private void init(string file=null)
        {
            this.mainViewport.Children.Remove(c);
            this.mainViewport.Children.Remove(touchFaces);

            rotations.Children.Clear();
            doneMoves.Clear();

            solveMenu.IsEnabled = false;

            if (file != null) {
                c = new RubikCube(IO.read(file, out doneMoves), size, new Point3D(-len / 2, -len / 2, -len / 2), TimeSpan.FromMilliseconds(370), edge_len, space);
            }
            else{
                c = new RubikCube(size, new Point3D(-len / 2, -len / 2, -len / 2), TimeSpan.FromMilliseconds(370), edge_len, space);
            }

            c.Transform = rotations;

            touchFaces = Helpers.createTouchFaces(len, size, rotations,
                    new DiffuseMaterial(new SolidColorBrush(Colors.Transparent)));

            this.mainViewport.Children.Add(c);
            this.mainViewport.Children.Add(touchFaces);

            if (!enableAnimations.IsChecked) {
                c.animationDuration = TimeSpan.FromMilliseconds(1);
            }

            if (file == null) {
                scramble(25);
            }

            gameOver = false;
            saveMenu.IsEnabled = true;
            solveMenu.IsEnabled = true;
        }
Example #3
0
        static public List <KeyValuePair <Move, RotationDirection> > Normalization(RubikCube c)
        {
            if (c.projection.projection[1, 4].ToString() == "B" & c.projection.projection[10, 4].ToString() == "R")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                return(SolveMoves);
            }
            else if (c.projection.projection[1, 4].ToString() == "B" & c.projection.projection[10, 4].ToString() == "D")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                return(SolveMoves);
            }
            else if (c.projection.projection[1, 4].ToString() == "B" & c.projection.projection[10, 4].ToString() == "L")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "U" & c.projection.projection[10, 4].ToString() == "F")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                return(SolveMoves);
            }
            else if (c.projection.projection[1, 4].ToString() == "U" & c.projection.projection[10, 4].ToString() == "R")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "U" & c.projection.projection[10, 4].ToString() == "B")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "U" & c.projection.projection[10, 4].ToString() == "L")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                return(SolveMoves);
            }



            else if (c.projection.projection[1, 4].ToString() == "F")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "R")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "U"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "E"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "D"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "D" & c.projection.projection[10, 4].ToString() == "B")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "D" & c.projection.projection[10, 4].ToString() == "R")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "D" & c.projection.projection[10, 4].ToString() == "F")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "D" & c.projection.projection[10, 4].ToString() == "L")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "F"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "S"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "B"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));

                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "R"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "M"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "L"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                return(SolveMoves);
            }

            else if (c.projection.projection[1, 4].ToString() == "L")
            {
                List <KeyValuePair <Move, RotationDirection> > SolveMoves = new List <KeyValuePair <Move, RotationDirection> >();
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "U"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "CounterClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "E"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                SolveMoves.Add(new KeyValuePair <Move, RotationDirection>((Move)Enum.Parse(typeof(Move), "D"),
                                                                          (RotationDirection)Enum.Parse(typeof(RotationDirection), "ClockWise")));
                return(SolveMoves);
            }
            else
            {
                return(null);
            }
        }