Ejemplo n.º 1
0
    def test_got_nothing(self, basic_patch):
        other_patch = Patch(12345)
        for i in range(len(basic_patch.characters)):
            other_patch.add_line("." * len(basic_patch.characters[0]))

        for base_side in Patch.SIDES:
            encoding = basic_patch.match(base_side=base_side,
                                         other=other_patch)
            assert encoding is None
Ejemplo n.º 2
0
    def test_complex_case(self, basic_patch):
        other_patch = Patch(12345)
        characters = [
            "#....#", "......", "......", "......", "#.....", "..#.#."
        ]
        for line in characters:
            other_patch.add_line(line)

        assert basic_patch.match(base_side=0, other=other_patch) == \
               {"base_side": 0, "rotations": 3, "flip": False}
        assert other_patch.match(base_side=3, other=basic_patch) == \
               {"base_side": 3, "rotations": 1, "flip": False}

        assert basic_patch.match(base_side=2, other=other_patch) == \
               {"base_side": 2, "rotations": 0, "flip": True}
        assert other_patch.match(base_side=0, other=basic_patch) == \
               {"base_side": 0, "rotations": 0, "flip": True}

        assert basic_patch.match(base_side=3, other=other_patch) == \
               {"base_side": 3, "rotations": 3, "flip": True}
        assert other_patch.match(base_side=2, other=basic_patch) == \
               {"base_side": 2, "rotations": 1, "flip": True}
Ejemplo n.º 3
0
    def test_construction(self):
        patch = Patch(12345)
        patch.add_line(".###..\n")
        patch.add_line(".#.#..\n")
        patch.add_line("....##\n")
        patch.add_line("....#.\n")
        patch.add_line("....##\n")
        patch.add_line("#...#.\n")

        assert patch.tile == 12345
        assert patch.characters == [
            ".###..", ".#.#..", "....##", "....#.", "....##", "#...#."
        ]
        assert patch.position is None
        assert patch.sides_covered == []
        assert patch.sides_ruled_out == []
Ejemplo n.º 4
0
def basic_patch():
    basic = Patch(2605)
    characters = [".###..", ".#.#..", "....##", "....#.", "....##", "#...#."]
    for line in characters:
        basic.add_line(line)
    return basic
Ejemplo n.º 5
0
 def make_patch(tile, lines, position):
     patch = Patch(tile)
     for line in lines:
         patch.add_line(line)
     patch.position = numpy.array(position)
     patchmap.add(patch)