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)
def generate(self, game, title=None): size = game.game_info.board_size num = 1 for node in [x for x in game.root.next_nodes if x.move is None]: board = Board(size) board.apply(node) if title is not None: board.name = "{} {}".format(title, num) num += 1 yield board
def create_board_13x13(self): board = Board(13) board.comment = "Board for test" board.name = "Board 13x13" node = Node() node.stone = Stone.Black node.marker = Square() board[1, 1] = node return board