Exemple #1
0
    def test_legal_merge_groups(self):

        myBoard = GoBoard(9, 9)

        g1_stones = [BoardLocation(1, 1), BoardLocation(1, 2)]
        g1_liberties = [BoardLocation(0, 0)]

        g2_stones = [BoardLocation(1, 3)]
        g2_liberties = [BoardLocation(0, 3)]

        g3_stones = [BoardLocation(1, 5)]
        g3_liberties = [BoardLocation(2, 5)]

        groups = [
            GoString(True, g1_stones, g1_liberties),
            GoString(True, g2_stones, g2_liberties),
            GoString(True, g3_stones, g3_liberties)
        ]
        merged_group = myBoard.merge_groups(groups)

        # Check that all three have their items in the merged_group
        self.assertEqual(len(merged_group.stones), 4)
        self.assertEqual(len(merged_group.liberties), 3)
        self.assertEqual(BoardLocation(1, 1) in merged_group.stones, True)
        self.assertEqual(BoardLocation(1, 2) in merged_group.stones, True)
        self.assertEqual(BoardLocation(1, 3) in merged_group.stones, True)
        self.assertEqual(BoardLocation(1, 5) in merged_group.stones, True)

        self.assertEqual(BoardLocation(0, 0) in merged_group.liberties, True)
        self.assertEqual(BoardLocation(0, 3) in merged_group.liberties, True)
        self.assertEqual(BoardLocation(2, 5) in merged_group.liberties, True)
Exemple #2
0
    def test_illegal_merge_groups(self):

        myBoard = GoBoard(9, 9)
        merged_group = myBoard.merge_groups([])
        isNone = (merged_group == None)
        self.assertEqual(isNone, True)