Exemple #1
0
def rook_take_test():
    print("========================================")
    print("Performing the rook take test")
    print("========================================")
    board = Board()
    piece = Rook(Colour.WHITE)
    current_location = Location('a', 1)
    board.__add_piece__(piece, current_location)

    friend_piece = Pawn(Colour.WHITE)
    enemy_piece = Pawn(Colour.BLACK)

    board.__add_piece__(friend_piece, Location('a', 2))
    board.__add_piece__(enemy_piece, Location('b', 1))

    print("Added a Rook and 2 pawns to the board...")

    print(board)
    allowed_moves = piece.allowed_moves(current_location, board)
    print("For a {} {} starting at position {} the moves are:".format(
        piece.colour, piece.name, current_location))
    print(allowed_moves)

    new_location = allowed_moves[0]
    board.move_piece(piece, current_location, new_location)
    current_location = new_location
    print("Moved the {} to position {}".format(piece.name, new_location))
    print(board)
    print("For a {} {} at position {} the moves are:".format(
        piece.colour, piece.name, current_location))
    print(piece.allowed_moves(current_location, board))
Exemple #2
0
def basic_rook_test():
    print("========================================")
    print("Performing the basic rook movement test")
    print("========================================")
    board = Board()
    piece = Rook(Colour.WHITE)
    current_location = Location('d', 5)
    board.__add_piece__(piece, current_location)
    print(board)

    allowed_moves = piece.allowed_moves(current_location, board)
    print("For a {} {} starting at position {} the moves are:".format(
        piece.colour, piece.name, current_location))
    print(allowed_moves)

    new_location = allowed_moves[0]
    board.move_piece(piece, current_location, new_location)
    current_location = new_location
    print("Moved the {} to position {}".format(piece.name, new_location))
    print(board)
    print("For a {} {} at position {} the moves are:".format(
        piece.colour, piece.name, current_location))
    print(piece.allowed_moves(current_location, board))