コード例 #1
0
ファイル: test_Cube.py プロジェクト: yakik/rubikCubeSolver
 def test_overallTest(self):
     myRubik = Cube()
     myRubik2 = Cube()
     myRubik.rotate_face("FRONT", "CW")
     self.assertEqual(8, myRubik.count_all_differences(myRubik2))
     myRubik.rotate_face("TOP", "CW")
     self.assertEqual(13, myRubik.count_all_differences(myRubik2))
コード例 #2
0
 def test_getValue(self):
     myRubik = Cube()
     myRubik.rotate_face("FRONT", "CW")
     myPermutation = Cube(myRubik)
     self.assertEqual(10, Cube.get_value(myPermutation, 1), "first floor")
     self.assertEqual(14, Cube.get_value(
         myPermutation, 2), "second floor")
     self.assertEqual(24, Cube.get_value(myPermutation, 3), "third floor")
コード例 #3
0
ファイル: test_Cube.py プロジェクト: yakik/rubikCubeSolver
 def test_rotateBackCounterClockwise(self):
     #Colors for : Front, Back, Right, Left, Top and Bottom  faces
     myRubik = Cube()
     myRubik.rotate_face("BACK", "CCW")
     self.assertEqual("LEFTCOLOR", myRubik.get_color("TOP", "LIF_TOP"))
     self.assertEqual("LEFTCOLOR", myRubik.get_color("TOP", "LIF_TOPRIGHT"))
     self.assertEqual("LEFTCOLOR", myRubik.get_color("TOP", "LIF_TOPLEFT"))
     self.assertEqual("BACKCOLOR",
                      myRubik.get_color("BACK", "LIF_BOTTOMLEFT"))
     myRubik.rotate_face("BACK", "CCW")
     myRubik.rotate_face("BACK", "CCW")
     myRubik.rotate_face("BACK", "CCW")
     self.assertEqual("TOPCOLOR", myRubik.get_color("TOP", "LIF_TOP"))
     self.assertEqual("TOPCOLOR", myRubik.get_color("TOP", "LIF_TOPRIGHT"))
     self.assertEqual("TOPCOLOR", myRubik.get_color("TOP", "LIF_TOPLEFT"))
     self.assertEqual("BACKCOLOR",
                      myRubik.get_color("BACK", "LIF_BOTTOMLEFT"))
コード例 #4
0
ファイル: test_Cube.py プロジェクト: yakik/rubikCubeSolver
 def test_rotateRightClockwise(self):
     #Colors for : Front, Back, Right, Left, Top and Bottom  faces
     myRubik = Cube()
     myRubik.rotate_face("RIGHT", "CW")
     self.assertEqual("FRONTCOLOR", myRubik.get_color("TOP", "LIF_RIGHT"))
     self.assertEqual("FRONTCOLOR",
                      myRubik.get_color("TOP", "LIF_BOTTOMRIGHT"))
     self.assertEqual("FRONTCOLOR",
                      myRubik.get_color("TOP", "LIF_TOPRIGHT"))
     self.assertEqual("RIGHTCOLOR",
                      myRubik.get_color("RIGHT", "LIF_BOTTOMLEFT"))
     myRubik.rotate_face("RIGHT", "CW")
     myRubik.rotate_face("RIGHT", "CW")
     myRubik.rotate_face("RIGHT", "CW")
     self.assertEqual("TOPCOLOR", myRubik.get_color("TOP", "LIF_RIGHT"))
     self.assertEqual("TOPCOLOR", myRubik.get_color("TOP",
                                                    "LIF_BOTTOMRIGHT"))
     self.assertEqual("TOPCOLOR", myRubik.get_color("TOP", "LIF_TOPRIGHT"))
     self.assertEqual("RIGHTCOLOR",
                      myRubik.get_color("RIGHT", "LIF_BOTTOMLEFT"))
コード例 #5
0
ファイル: forProfiler.py プロジェクト: yakik/rubikCubeSolver
from production.cube.cube import Cube
from production.solver.solver import Solver
from production.cube.rubik_file_reader import Rubik_file_reader
from production.solver.rotation_tree import Rotation_tree

myRubik = Cube()
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("LEFT", "CW")
myRubik.rotate_face("FRONT", "CW")
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("LEFT", "CW")
myRubik.rotate_face("FRONT", "CW")
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("LEFT", "CW")
myRubik.rotate_face("FRONT", "CW")
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("RIGHT", "CW")
myRubik.rotate_face("BACK", "CW")
myRubik.rotate_face("LEFT", "CW")
myRubik.rotate_face("FRONT", "CW")
myRubik.rotate_face("RIGHT", "CW")
コード例 #6
0
ファイル: test_Solver.py プロジェクト: yakik/rubikCubeSolver
    def test_complexSolver(self):
        myRubik = Cube()
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        myRubik.rotate_face("BACK", "CW")
        myRubik.rotate_face("LEFT", "CW")
        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("RIGHT", "CW")
        mySolver = Solver()

        readFirstFloor = Rubik_file_reader(
            "c:\\Users\\yk700h\\dev\\rubikCubeSolver\\python\\Resources\\FirstFloor.txt"
        )
        readSecondFloor = Rubik_file_reader(
            "c:\\Users\\yk700h\\dev\\rubikCubeSolver\\python\\Resources\\SecondFloor.txt"
        )
        readThirdFloor = Rubik_file_reader(
            "c:\\Users\\yk700h\\dev\\rubikCubeSolver\\python\\Resources\\ThirdFloor.txt"
        )

        firstFloorTree = Rotation_tree.get_rotation_tree_from_file(
            readFirstFloor)
        readFirstFloor.close()
        secondFloorTree = Rotation_tree.get_rotation_tree_from_file(
            readSecondFloor)
        readSecondFloor.close()
        thirdFloorTree = Rotation_tree.get_rotation_tree_from_file(
            readThirdFloor)
        readThirdFloor.close()
        #System.out.format("****************")
        mySolution = mySolver.solve(myRubik, firstFloorTree, secondFloorTree,
                                    thirdFloorTree)
        #System.out.format("****************")
        mySolution.apply_to_rubik(myRubik)
        mySolution.print()
        # long endTime = System.n nanoTime()
        #Console.WriteLine("Elapsed Time=%d seconds", ((endTime - beginningTime) / 1000000000))
        #27-12-2017: started 11:39 PM, Failed
        #myRubik.print()
        self.assertTrue(myRubik.equals(Cube()))
コード例 #7
0
ファイル: test_Cube.py プロジェクト: yakik/rubikCubeSolver
    def test_simpleRotations(self):
        myRubik = Cube()
        for i in range(0, 20):
            myRubik.rotate_face("TOP", "CW")
            myRubik.rotate_face("RIGHT", "CW")
            myRubik.rotate_face("LEFT", "CW")
            myRubik.rotate_face("BOTTOM", "CW")
            myRubik.rotate_face("RIGHT", "CW")
            myRubik.rotate_face("TOP", "CW")
            myRubik.rotate_face("RIGHT", "CW")
            myRubik.rotate_face("BACK", "CW")
            myRubik.rotate_face("LEFT", "CW")
            myRubik.rotate_face("FRONT", "CW")

        for i in range(0, 20):
            myRubik.rotate_face("FRONT", "CCW")
            myRubik.rotate_face("LEFT", "CCW")
            myRubik.rotate_face("BACK", "CCW")
            myRubik.rotate_face("RIGHT", "CCW")
            myRubik.rotate_face("TOP", "CCW")
            myRubik.rotate_face("RIGHT", "CCW")
            myRubik.rotate_face("BOTTOM", "CCW")
            myRubik.rotate_face("LEFT", "CCW")
            myRubik.rotate_face("RIGHT", "CCW")
            myRubik.rotate_face("TOP", "CCW")

        myRubik.rotate_face("FRONT", "CW")
        myRubik.rotate_face("FRONT", "CCW")
        self.assertTrue(myRubik.equals(Cube()))