Beispiel #1
0
    def test_empty_node_first(self):
        game_node = GameNode()
        game_node.empty = [Point(1, 1)]
        game_node.move = Move(Stone.White, Point(1, 1))
        board = self.create_board_13x13()
        board.apply(game_node)

        board_expected = self.create_board_13x13()
        board_expected[1, 1] = Node(stone=Stone.White)
        self.assertEqual(board_expected, board)
Beispiel #2
0
    def test_снятие_камней_группа_в_углу(self):
        board = Board(13)\
            .white(1, 2).white(2, 2).white(2, 1)\
            .black(1, 3).black(2, 3).black(3, 1).black(3, 2)\

        game_node = GameNode()
        game_node.move = Move(Stone.Black, Point(1, 1))
        board.apply(game_node)

        board_expected = Board(13)\
            .black(1, 1)\
            .black(1, 3).black(2, 3).black(3, 1).black(3, 2)\

        self.assertEqual(board_expected, board)
Beispiel #3
0
    def test_снятие_камней_4_камня_в_центре(self):
        board = Board(13)\
            .white(7, 6).white(6, 7).white(8, 7).white(7, 8)\
            .black(7, 5).black(5, 7).black(9, 7).black(7, 9)\
            .black(8, 8).black(6, 6).black(8, 6).black(6, 8)

        game_node = GameNode()
        game_node.move = Move(Stone.Black, Point(7, 7))
        board.apply(game_node)

        board_expected = Board(13)\
            .black(7, 5).black(5, 7).black(9, 7).black(7, 9)\
            .black(8, 8).black(6, 6).black(8, 6).black(6, 8).black(7, 7)

        self.assertEqual(board_expected, board)
Beispiel #4
0
    def test_снятие_камней_1_камень(self):
        board = self.create_board_13x13()\
            .black(7, 7)\
            .white(6, 7)\
            .white(8, 7)\
            .white(7, 8)

        game_node = GameNode()
        game_node.move = Move(Stone.White, Point(7, 6))
        board.apply(game_node)

        board_expected = self.create_board_13x13()\
            .white(7, 6)\
            .white(6, 7)\
            .white(8, 7)\
            .white(7, 8)
        self.assertEqual(board_expected, board)
Beispiel #5
0
    def test_apply_move(self):
        game_node = GameNode()
        game_node.add_black = [Point(2, 2), Point(12, 12)]
        game_node.add_white = [Point(3, 3), Point(11, 11)]
        game_node.empty = [Point(1, 1)]
        game_node.move = Move(Stone.Black, Point(7, 7))
        game_node.markups = [(Triangle(), Point(7, 7)), (Circle(), Point(5, 5))]

        board = self.create_board_13x13()
        board.apply(game_node)

        board_expected = self.create_board_13x13()
        board_expected[1, 1] = None
        board_expected[2, 2] = Node(stone=Stone.Black)
        board_expected[12, 12] = Node(stone=Stone.Black)
        board_expected[3, 3] = Node(stone=Stone.White)
        board_expected[11, 11] = Node(stone=Stone.White)
        board_expected[5, 5] = Node(marker=Circle())
        board_expected[7, 7] = Node(stone=Stone.Black, marker=Triangle())

        self.assertEqual(board_expected, board)
Beispiel #6
0
    def test_impossible_move_stone_already_here(self):
        game_node = GameNode()
        game_node.move = Move(Stone.Black, Point(1, 1))
        board = self.create_board_13x13()

        self.assertRaises(ImpossibleMove, functools.partial(board.apply, game_node))