Пример #1
0
        static void Main(string[] args)
        {
            // Declare the cubes and thier sides based on a starting position
            a = new Cube(CubeSide.PlanetYellow, CubeSide.AmazingMan, CubeSide.AmazingMan, CubeSide.PlanetRed, CubeSide.AmazingSkull, CubeSide.PlanetYellow);
            b = new Cube(CubeSide.AmazingMan, CubeSide.PlanetYellow, CubeSide.AmazingSkull, CubeSide.PlanetRed, CubeSide.PlanetRed, CubeSide.AmazingMan);
            c = new Cube(CubeSide.AmazingSkull, CubeSide.PlanetRed, CubeSide.AmazingMan, CubeSide.PlanetRed, CubeSide.PlanetYellow, CubeSide.AmazingSkull);
            d = new Cube(CubeSide.PlanetYellow, CubeSide.AmazingSkull, CubeSide.PlanetYellow, CubeSide.AmazingMan, CubeSide.PlanetRed, CubeSide.PlanetYellow);

            // Count how many solutions (this was before I knew there was only 1)
            int solutionCount = 0;

            // Count how many positions are tried that are not solutions
            int invalidPositionCount = 0;

            // Rotate the first cube along its east-west axis
            for (int ae = 0; ae < 4; ae++)
            {
                // Rotate the first cube around its north-south axis
                for (int an = 0; an < 4; an++)
                {
                    // Second cube east-west
                    for (int be = 0; be < 4; be++)
                    {
                        // Second cube north-south
                        for (int bn = 0; bn < 4; bn++)
                        {
                            // Third cube east-west
                            for (int ce = 0; ce < 4; ce++)
                            {
                                // Third cube north-south
                                for (int cn = 0; cn < 4; cn++)
                                {
                                    // Fourth cube east-west
                                    for (int de = 0; de < 4; de++)
                                    {
                                        // Fourth cube north-south
                                        for (int dn = 0; dn < 4; dn++)
                                        {
                                            // Check every position
                                            if (CheckPositions())
                                            {
                                                // Solution!
                                                solutionCount++;
                                            }
                                            else
                                            {
                                                // Count as invalid position
                                                invalidPositionCount++;
                                            }

                                            d.Rotate(Orientation.North);
                                        }

                                        d.Rotate(Orientation.East);
                                    }

                                    c.Rotate(Orientation.North);
                                }

                                c.Rotate(Orientation.East);
                            }

                            b.Rotate(Orientation.North);
                        }

                        b.Rotate(Orientation.East);
                    }

                    a.Rotate(Orientation.North);
                }

                a.Rotate(Orientation.East);
            }

            Console.WriteLine();
            Console.WriteLine("Solutions: {0}", solutionCount.ToString());
            Console.WriteLine("Non Solutions: {0}", invalidPositionCount.ToString());

            Console.WriteLine();
            Console.WriteLine("Press any key to quit");
            Console.ReadLine();
        }
Пример #2
0
 static int HoldingSlotCount(FtlSlot slot, Cube cube) => HoldingSlots(slot.Home.Locate(cube)).Length;
Пример #3
0
        //

        public static byte[] Solve(Cube cube)
        {
            theSolution.Clear();
            IDA(cube);
            return(theSolution.ToArray());
        }
Пример #4
0
 static public CornerConstraint FindCornerAndSolveIt(Cube cube, Corner corner)
 {
     return(new CornerConstraint(corner.Locate(cube), corner));
 }
Пример #5
0
 static public EdgeConstraint FindEdgeAndSolveIt(Cube cube, Edge edge)
 {
     return(new EdgeConstraint(edge.Locate(cube), edge));
 }
Пример #6
0
 public Cube(Cube cubeToCopy, byte move)
 {
     //copy a cube with a move added
 }
Пример #7
0
 public Corner Examine(Cube cube)
 {
     return(new Corner(cube[Pos0], cube[Pos1], cube[Pos2]));
 }
Пример #8
0
 static void Assert_CrossSolved(Cube cube)
 {
     Assert.True(Constraints.CrossConstraint.IsMatch(cube), "cross not solved");
 }