コード例 #1
0
    def test_TileSet(self):
        s = pentominos.TileSet([pentominos.I(), pentominos.I()])
        self.assertEqual(s.size(), 1)

        reps = pentominos.TileSet()
        p = pentominos.Y()
        reps.add(p)
        p.flip(0)
        reps.add(p)
        p.flip(1)
        reps.add(p)
        p.flip(0)
        reps.add(p)
        self.assertEqual(reps.size(), 4)

        reps = pentominos.TileSet()
        p = pentominos.Y()
        reps.add(p)
        p.turn90()
        reps.add(p)
        p.turn90()
        reps.add(p)
        p.turn90()
        reps.add(p)
        self.assertEqual(reps.size(), 4)
コード例 #2
0
    def test_TileSet(self):
        s = pentominos.TileSet([pentominos.I(), pentominos.I()])
        self.assertEqual(s.size(), 1)

        reps = pentominos.TileSet()
        p = pentominos.Y()
        reps.add(p)
        p.flip(0)
        reps.add(p)
        p.flip(1)
        reps.add(p)
        p.flip(0)
        reps.add(p)
        self.assertEqual(reps.size(), 4)

        reps = pentominos.TileSet()
        p = pentominos.Y()
        reps.add(p)
        p.turn90()
        reps.add(p)
        p.turn90()
        reps.add(p)
        p.turn90()
        reps.add(p)
        self.assertEqual(reps.size(), 4)

        reps = pentominos.TileSet([pentominos.I(), pentominos.X()], {'I': 3})
        self.assertEqual({'I': 3, 'X': 0}, reps.stock)
コード例 #3
0
    def test_turn90(self):
        c0 = copy.deepcopy(pentominos.I().coos)
        self.assertEqual(c0, pentominos.I().turn90().turn90().coos)

        p = pentominos.Y()
        s = pentominos.TileSet()
        for i in range(4):
            s.add(p)
            p.turn90()
        self.assertEqual(4, s.size())
コード例 #4
0
    def test_turn90(self):
        c0 = copy.deepcopy(pentominos.I().coos)
        #self.assertEqual(c0, pentominos.I().turn90().turn90().coos)
        cnew = pentominos.I().turn90().turn90().coos
        for c in c0:
            self.assertTrue(c in cnew)
        for c in cnew:
            self.assertTrue(c in c0)

        p = pentominos.Y()
        s = pentominos.TileSet()
        for i in range(4):
            s.add(p)
            p.turn90()
        self.assertEqual(4, s.size())
コード例 #5
0
    def testMatrix(self):
        TSet = pentominos.TileSet([
            pentominos.F(),
            pentominos.I(),
            pentominos.L(),
            pentominos.P(),
            pentominos.N(),
            pentominos.T(),
            pentominos.U(),
            pentominos.V(),
            pentominos.W(),
            pentominos.Y(),
            pentominos.Z()
        ])
        names = [p.name for p in TSet]
        probX12 = scott.Problem(TSet, 8, self.legal1, 1, 0)
        probX13 = scott.Problem(TSet, 8, self.legal2, 1, 0)
        probX22 = scott.Problem(TSet, 8, self.legal3, 1, 1)
        str1 = probX12.IncMatrix.representation()
        probX12.completeMatrix()
        str2 = probX12.IncMatrix.representation()
        self.assertFalse(str1 == str2)

        str1 = probX13.IncMatrix.representation()
        probX13.completeMatrix()
        str2 = probX13.IncMatrix.representation()
        self.assertFalse(str1 == str2)

        str1 = probX22.IncMatrix.representation()
        probX22.completeMatrix()
        str2 = probX22.IncMatrix.representation()
        self.assertFalse(str1 == str2)

        probX12.solve()
        sol12 = probX12.solutionList
        self.assertEqual(len(sol12), 19)
        #print sol12
        # if sol12 != {}:
        # 	sol12 += "(X,[02,11,12,13,22])" #12

        probX13.solve()
        sol13 = probX13.solutionList
        self.assertEqual(len(sol13), 20)
        #print sol13
        # if sol13 != {}:
        # 	sol13 += "(X,[03,12,13,14,23])" #13

        probX22.solve()
        sol22 = probX22.solutionList
        self.assertEqual(len(sol22), 26)
コード例 #6
0
 def testSetup(self):
     TSet = pentominos.TileSet([
         pentominos.F(),
         pentominos.I(),
         pentominos.L(),
         pentominos.P(),
         pentominos.N(),
         pentominos.T(),
         pentominos.U(),
         pentominos.V(),
         pentominos.W(),
         pentominos.X(),
         pentominos.Y(),
         pentominos.Z()
     ])
     names = [p.name for p in TSet]
     for n in ["F", "I", "L", "P", "N", "T", "U", "V", "W", "X", "Y", "Z"]:
         self.assertTrue(n in names)
     for n in names:
         self.assertTrue(
             n in
             ["F", "I", "L", "P", "N", "T", "U", "V", "W", "X", "Y", "Z"])
     prob = scott.Problem(TSet, 8, self.legal, 1, 0)
コード例 #7
0
 def test_set(self):
     s = set([pentominos.I(), pentominos.I()])
     self.assertEqual(len(s), 1)
コード例 #8
0
 def test_max(self):
     self.assertEqual([0, 4], pentominos.I().max())
     self.assertEqual([2, 2], pentominos.F().max())
コード例 #9
0
 def test_translate(self):
     self.assertEqual([[c[0] + 1, c[1]] for c in pentominos.I().coos],
                      pentominos.I().translate_one(0).coos)
     self.assertEqual([[c[0], c[1] + 1] for c in pentominos.I().coos],
                      pentominos.I().translate_one(1).coos)