def test_simple_book_generator(self):
        child1 = GameNode()
        child1.add_black = [Point(7, 7)]

        child2 = GameNode()
        child2.add_white = [Point(3, 3)]
        child2.add_black = [Point(5, 5)]

        child3 = GameNode()
        child3.add_black = [Point(11, 11)]

        root = GameNode()
        root.add_next_node(child1)
        root.add_next_node(child2)
        root.add_next_node(child3)

        game = Game(13)
        game.game_info = GameInfo()
        game.game_info.board_size = 13
        game.root = root

        board1 = Board(13).black(7, 7)
        board2 = Board(13).white(3, 3).black(5, 5)
        board3 = Board(13).black(11, 11)

        board1.name = "Problem 1"
        board2.name = "Problem 2"
        board3.name = "Problem 3"

        expected = [board1, board2, board3]

        generator = ProblemsBookGenerator()

        actual = [x for x in generator.generate(game, title="Problem")]
        self.assertEqual(expected, actual)
Exemple #2
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)