예제 #1
0
파일: Cube.cs 프로젝트: noelle/RubiksCube
        /// <summary>
        /// Creates a solvable Cube
        /// </summary>
        private void createSolvableCube()
        {
            Cubie frontCubie1 = new Cubie(CubieType.Corner, 1, -1, 1, CubieColor.Y, CubieColor.B, CubieColor.O);
            Cubie frontCubie2 = new Cubie(CubieType.Edge, 1, 0, 1, CubieColor.R, CubieColor.None, CubieColor.W);
            Cubie frontCubie3 = new Cubie(CubieType.Corner, 1, 1, 1, CubieColor.O, CubieColor.W, CubieColor.B);
            Cubie frontCubie4 = new Cubie(CubieType.Edge, 1, -1, 0, CubieColor.G, CubieColor.Y, CubieColor.None);
            Cubie frontCubie5 = new Cubie(CubieType.Center, 1, 0, 0, CubieColor.G, CubieColor.None, CubieColor.None);
            Cubie frontCubie6 = new Cubie(CubieType.Edge, 1, 1, 0, CubieColor.R, CubieColor.B, CubieColor.None);
            Cubie frontCubie7 = new Cubie(CubieType.Corner, 1, -1, -1, CubieColor.R, CubieColor.Y, CubieColor.B);
            Cubie frontCubie8 = new Cubie(CubieType.Edge, 1, 0, -1, CubieColor.W, CubieColor.None, CubieColor.G);
            Cubie frontCubie9 = new Cubie(CubieType.Corner, 1, 1, -1, CubieColor.R, CubieColor.W, CubieColor.B);

            Cubie backCubie1 = new Cubie(CubieType.Corner, -1, -1, -1, CubieColor.Y, CubieColor.O, CubieColor.G);
            Cubie backCubie2 = new Cubie(CubieType.Edge, -1, 0, -1, CubieColor.B, CubieColor.None, CubieColor.O);
            Cubie backCubie3 = new Cubie(CubieType.Corner, -1, 1, -1, CubieColor.O, CubieColor.G, CubieColor.W);
            Cubie backCubie4 = new Cubie(CubieType.Edge, -1, -1, 0, CubieColor.W, CubieColor.O, CubieColor.None);
            Cubie backCubie5 = new Cubie(CubieType.Center, -1, 0, 0, CubieColor.B, CubieColor.None, CubieColor.None);
            Cubie backCubie6 = new Cubie(CubieType.Edge, -1, 1, 0, CubieColor.Y, CubieColor.R, CubieColor.None);
            Cubie backCubie7 = new Cubie(CubieType.Corner, -1, -1, 1, CubieColor.G, CubieColor.Y, CubieColor.R);
            Cubie backCubie8 = new Cubie(CubieType.Edge, -1, 0, 1, CubieColor.O, CubieColor.None, CubieColor.Y);
            Cubie backCubie9 = new Cubie(CubieType.Corner, -1, 1, 1, CubieColor.G, CubieColor.W, CubieColor.R);

            Cubie middleCubie1 = new Cubie(CubieType.Edge, 0, -1, 1, CubieColor.None, CubieColor.B, CubieColor.W);
            Cubie middleCubie2 = new Cubie(CubieType.Center, 0, 0, 1, CubieColor.None, CubieColor.None, CubieColor.W);
            Cubie middleCubie3 = new Cubie(CubieType.Edge, 0, 1, 1, CubieColor.None, CubieColor.O, CubieColor.G);
            Cubie middleCubie4 = new Cubie(CubieType.Center, 0, 1, 0, CubieColor.None, CubieColor.R, CubieColor.None);
            Cubie middleCubie5 = new Cubie(CubieType.Edge, 0, 1, -1, CubieColor.None, CubieColor.B, CubieColor.Y);
            Cubie middleCubie6 = new Cubie(CubieType.Center, 0, 0, -1, CubieColor.None, CubieColor.None, CubieColor.Y);
            Cubie middleCubie7 = new Cubie(CubieType.Edge, 0, -1, -1, CubieColor.None, CubieColor.R, CubieColor.G);
            Cubie middleCubie8 = new Cubie(CubieType.Center, 0, -1, 0, CubieColor.None, CubieColor.O, CubieColor.None);

            solvableCube.Add(frontCubie1);
            solvableCube.Add(frontCubie2);
            solvableCube.Add(frontCubie3);
            solvableCube.Add(frontCubie4);
            solvableCube.Add(frontCubie5);
            solvableCube.Add(frontCubie6);
            solvableCube.Add(frontCubie7);
            solvableCube.Add(frontCubie8);
            solvableCube.Add(frontCubie9);

            solvableCube.Add(backCubie1);
            solvableCube.Add(backCubie2);
            solvableCube.Add(backCubie3);
            solvableCube.Add(backCubie4);
            solvableCube.Add(backCubie5);
            solvableCube.Add(backCubie6);
            solvableCube.Add(backCubie7);
            solvableCube.Add(backCubie8);
            solvableCube.Add(backCubie9);

            solvableCube.Add(middleCubie1);
            solvableCube.Add(middleCubie2);
            solvableCube.Add(middleCubie3);
            solvableCube.Add(middleCubie4);
            solvableCube.Add(middleCubie5);
            solvableCube.Add(middleCubie6);
            solvableCube.Add(middleCubie7);
            solvableCube.Add(middleCubie8);
        }
예제 #2
0
파일: Cube.cs 프로젝트: noelle/RubiksCube
        /// <summary>
        /// Returns a cubie by colors
        /// </summary>
        /// <param name="col1">color 1</param>
        /// <param name="col2">color 2</param>
        /// <param name="col3">color 3</param>
        /// <returns></returns>
        public Cubie getCubie(CubieColor col1, CubieColor col2, CubieColor col3)
        {
            Cubie cube = this.cubies.Where(q => ((q.ColX == col1 && q.ColY == col2 && q.ColZ == col3) ||
                                                 (q.ColX == col1 && q.ColY == col3 && q.ColZ == col2) ||
                                                 (q.ColX == col2 && q.ColY == col1 && q.ColZ == col3) ||
                                                 (q.ColX == col2 && q.ColY == col3 && q.ColZ == col1) ||
                                                 (q.ColX == col3 && q.ColY == col1 && q.ColZ == col2) ||
                                                 (q.ColX == col3 && q.ColY == col2 && q.ColZ == col1))).Select(q => q).FirstOrDefault();

            return(cube);
        }
예제 #3
0
파일: Cubie.cs 프로젝트: noelle/RubiksCube
        public override bool Equals(object obj)
        {
            Cubie cmpCubie = (Cubie)obj;

            if (cmpCubie != null)
            {
                if (cmpCubie.posX == this.posX && cmpCubie.posY == this.posY && cmpCubie.posZ == this.posZ)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
파일: Cube.cs 프로젝트: noelle/RubiksCube
        /// <summary>
        /// Creates a solvable Cube
        /// </summary>
        private void createSolvableCube()
        {
            Cubie frontCubie1 = new Cubie(CubieType.Corner, 1, -1, 1, CubieColor.Y, CubieColor.B, CubieColor.O);
            Cubie frontCubie2 = new Cubie(CubieType.Edge, 1, 0, 1, CubieColor.R, CubieColor.None, CubieColor.W);
            Cubie frontCubie3 = new Cubie(CubieType.Corner, 1, 1, 1, CubieColor.O, CubieColor.W, CubieColor.B);
            Cubie frontCubie4 = new Cubie(CubieType.Edge, 1, -1, 0, CubieColor.G, CubieColor.Y, CubieColor.None);
            Cubie frontCubie5 = new Cubie(CubieType.Center, 1, 0, 0, CubieColor.G, CubieColor.None, CubieColor.None);
            Cubie frontCubie6 = new Cubie(CubieType.Edge, 1, 1, 0, CubieColor.R, CubieColor.B, CubieColor.None);
            Cubie frontCubie7 = new Cubie(CubieType.Corner, 1, -1, -1, CubieColor.R, CubieColor.Y, CubieColor.B);
            Cubie frontCubie8 = new Cubie(CubieType.Edge, 1, 0, -1, CubieColor.W, CubieColor.None, CubieColor.G);
            Cubie frontCubie9 = new Cubie(CubieType.Corner, 1, 1, -1, CubieColor.R, CubieColor.W, CubieColor.B);

            Cubie backCubie1 = new Cubie(CubieType.Corner, -1, -1, -1, CubieColor.Y, CubieColor.O, CubieColor.G);
            Cubie backCubie2 = new Cubie(CubieType.Edge, -1, 0, -1, CubieColor.B, CubieColor.None, CubieColor.O);
            Cubie backCubie3 = new Cubie(CubieType.Corner, -1, 1, -1, CubieColor.O, CubieColor.G, CubieColor.W);
            Cubie backCubie4 = new Cubie(CubieType.Edge, -1, -1, 0, CubieColor.W, CubieColor.O, CubieColor.None);
            Cubie backCubie5 = new Cubie(CubieType.Center, -1, 0, 0, CubieColor.B, CubieColor.None, CubieColor.None);
            Cubie backCubie6 = new Cubie(CubieType.Edge, -1, 1, 0, CubieColor.Y, CubieColor.R, CubieColor.None);
            Cubie backCubie7 = new Cubie(CubieType.Corner, -1, -1, 1, CubieColor.G, CubieColor.Y, CubieColor.R);
            Cubie backCubie8 = new Cubie(CubieType.Edge, -1, 0, 1, CubieColor.O, CubieColor.None, CubieColor.Y);
            Cubie backCubie9 = new Cubie(CubieType.Corner, -1, 1, 1, CubieColor.G, CubieColor.W, CubieColor.R);

            Cubie middleCubie1 = new Cubie(CubieType.Edge, 0, -1, 1, CubieColor.None, CubieColor.B, CubieColor.W);
            Cubie middleCubie2 = new Cubie(CubieType.Center, 0, 0, 1, CubieColor.None, CubieColor.None, CubieColor.W);
            Cubie middleCubie3 = new Cubie(CubieType.Edge, 0, 1, 1, CubieColor.None, CubieColor.O, CubieColor.G);
            Cubie middleCubie4 = new Cubie(CubieType.Center, 0, 1, 0, CubieColor.None, CubieColor.R, CubieColor.None);
            Cubie middleCubie5 = new Cubie(CubieType.Edge, 0, 1, -1, CubieColor.None, CubieColor.B, CubieColor.Y);
            Cubie middleCubie6 = new Cubie(CubieType.Center, 0, 0, -1, CubieColor.None, CubieColor.None, CubieColor.Y);
            Cubie middleCubie7 = new Cubie(CubieType.Edge, 0, -1, -1, CubieColor.None, CubieColor.R, CubieColor.G);
            Cubie middleCubie8 = new Cubie(CubieType.Center, 0, -1, 0, CubieColor.None, CubieColor.O, CubieColor.None);

            solvableCube.Add(frontCubie1);
            solvableCube.Add(frontCubie2);
            solvableCube.Add(frontCubie3);
            solvableCube.Add(frontCubie4);
            solvableCube.Add(frontCubie5);
            solvableCube.Add(frontCubie6);
            solvableCube.Add(frontCubie7);
            solvableCube.Add(frontCubie8);
            solvableCube.Add(frontCubie9);

            solvableCube.Add(backCubie1);
            solvableCube.Add(backCubie2);
            solvableCube.Add(backCubie3);
            solvableCube.Add(backCubie4);
            solvableCube.Add(backCubie5);
            solvableCube.Add(backCubie6);
            solvableCube.Add(backCubie7);
            solvableCube.Add(backCubie8);
            solvableCube.Add(backCubie9);

            solvableCube.Add(middleCubie1);
            solvableCube.Add(middleCubie2);
            solvableCube.Add(middleCubie3);
            solvableCube.Add(middleCubie4);
            solvableCube.Add(middleCubie5);
            solvableCube.Add(middleCubie6);
            solvableCube.Add(middleCubie7);
            solvableCube.Add(middleCubie8);
        }