Ejemplo n.º 1
0
def test_imgage_processor():
    '''Test image processor (multiple tests)'''

    expected_board = BlindBoard.get_starting_board()
    expected_board.remove_piece_at(chess.E2)
    expected_board.set_piece_at(chess.E4, Piece(PAWN, WHITE))

    # retrieve all the images paths and sort
    images = collect_test_images('tests/pictures/game000')
    debug("Calibrating image processor...")
    processor = ImageProcessor(images[0], images[1])

    for img, expected_board in zip(images[2:], expected_boards()):
        debug("Processing `{}`...".format(os.path.basename(img)))
        processor.process(img)
        board = processor.get_blindboard()
        yield compare_blindboards, expected_board, board, img
Ejemplo n.º 2
0
def test_imgage_processor():
    '''Test image processor (multiple tests)'''

    expected_board = BlindBoard.get_starting_board()
    expected_board.remove_piece_at(chess.E2)
    expected_board.set_piece_at(chess.E4, Piece(PAWN, WHITE))

    # retrieve all the images paths and sort
    images = collect_test_images('tests/pictures/game000')
    debug("Calibrating image processor...")
    processor = ImageProcessor(images[0], images[1])

    for img, expected_board in zip(images[2:], expected_boards()):
        debug("Processing `{}`...".format(os.path.basename(img)))
        processor.process(img)
        board = processor.get_blindboard()
        yield compare_blindboards, expected_board, board, img
Ejemplo n.º 3
0
def expected_boards():
    '''This generator returns all the BlindBoards corresponding to the
    images inside ./pictures (starting with board-2.jpg)'''
    b = BlindBoard.get_starting_board()
    b.move_piece(chess.E2, chess.E4)
    yield b  # board-2.jpg
    b.move_piece(chess.E7, chess.E5)
    yield b
    b.move_piece(chess.G1, chess.F3)
    yield b
    b.move_piece(chess.B8, chess.C6)
    yield b
    b.move_piece(chess.F1, chess.B5)
    yield b
    b.move_piece(chess.G8, chess.F6)
    yield b
    b.move_piece(chess.E1, chess.F1)
    b.move_piece(chess.H1, chess.G1)
    yield b
    b.remove_piece_at(chess.F6)
    b.change_color_at(chess.E4)
    yield b
    b.move_piece(chess.D1, chess.E2)
    yield b
    b.move_piece(chess.D7, chess.D5)
    yield b
    b.remove_piece_at(chess.F3)
    b.change_color_at(chess.E5)
    yield b
    b.move_piece(chess.C8, chess.D7)
    yield b
    b.remove_piece_at(chess.E5)
    b.change_color_at(chess.C6)
    yield b
    b.remove_piece_at(chess.B7)
    b.change_color_at(chess.C6)
    yield b
    b.move_piece(chess.B5, chess.D3)
    yield b
Ejemplo n.º 4
0
def expected_boards():
    '''This generator returns all the BlindBoards corresponding to the
    images inside ./pictures (starting with board-2.jpg)'''
    b = BlindBoard.get_starting_board()
    b.move_piece(chess.E2, chess.E4)
    yield b  # board-2.jpg
    b.move_piece(chess.E7, chess.E5)
    yield b
    b.move_piece(chess.G1, chess.F3)
    yield b
    b.move_piece(chess.B8, chess.C6)
    yield b
    b.move_piece(chess.F1, chess.B5)
    yield b
    b.move_piece(chess.G8, chess.F6)
    yield b
    b.move_piece(chess.E1, chess.F1)
    b.move_piece(chess.H1, chess.G1)
    yield b
    b.remove_piece_at(chess.F6)
    b.change_color_at(chess.E4)
    yield b
    b.move_piece(chess.D1, chess.E2)
    yield b
    b.move_piece(chess.D7, chess.D5)
    yield b
    b.remove_piece_at(chess.F3)
    b.change_color_at(chess.E5)
    yield b
    b.move_piece(chess.C8, chess.D7)
    yield b
    b.remove_piece_at(chess.E5)
    b.change_color_at(chess.C6)
    yield b
    b.remove_piece_at(chess.B7)
    b.change_color_at(chess.C6)
    yield b
    b.move_piece(chess.B5, chess.D3)
    yield b
Ejemplo n.º 5
0
    def setUp(self):

        self.bb_start = BlindBoard.get_starting_board()
Ejemplo n.º 6
0
    def setUp(self):

        self.bb_start = BlindBoard.get_starting_board()