question: public static double [ ] createRandomGridValues ( int width , int height , double min , double max , int numIterations , double smoothness ) { int numValues = width * height ; double [ ] values = new double [ numValues ] ; for ( int i = 0 ; i < numIterations ; i ++ ) { double offset = 1d - ( i / ( double ) numIterations ) ; int x1 = ( int ) Math . round ( Math . random ( ) * ( width - 1 ) ) ; int x2 = ( int ) Math . round ( Math . random ( ) * ( width - 1 ) ) ; int y1 = ( int ) Math . round ( Math . random ( ) * ( height - 1 ) ) ; int y2 = ( int ) Math . round ( Math . random ( ) * ( height - 1 ) ) ; int dx1 = x2 - x1 ; int dy1 = y2 - y1 ; for ( int y = 0 ; y < height ; y ++ ) { int dy2 = y - y1 ; for ( int x = 0 ; x < width ; x ++ ) { int dx2 = x - x1 ; if ( ( dx2 * dy1 - dx1 * dy2 ) >= 0 ) values [ x + y * width ] += offset ; } } } smoothValues ( width , height , values , smoothness ) ; scaleValues ( values , numValues , min , max ) ; return values ; }
target:  Creates a 2D grid of random values with an optional smoothing parameter. Random grid values are in the range from min to max, inclusive. Increasing the number of iterations results in a less uniform grid.