Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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())
Exemplo n.º 4
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)
Exemplo n.º 5
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())
Exemplo n.º 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)
Exemplo n.º 7
0
# print p2.representation()
# print p2.__hash__()
# print p.__eq__(p2)
# p.flip(1)
# print p.representation()
# print p.__hash__()
# p.flip(0)
# print p.representation()
# print p.__hash__()

# X = pentominos.TileSet()
# p = pentominos.I()
# X.add(copy.deepcopy(p))
# p.flip(0)
# #p.turn90()
# X.add(copy.deepcopy(p))
# print X.representation()

reps = pentominos.TileSet()
p = pentominos.Y()
print reps.representation()
reps.add(p)
print reps.representation()
p.flip(0)
print reps.representation()
reps.add(p)
print reps.representation()
p.flip(1)
reps.add(p)
p.flip(0)
reps.add(p)