How to implement Perlin Noise into this Code

This code generates a set of voxels in a radius of amt. They have no z height and I would like to implement a Perkin noise heightmap to this, but need help to integrate it:

amt = 128
for x in range (-amt, amt):
for y in range (-amt, amt):
pos = [x, y, 0]
block_positions = [ ]
if pos not in block_positions:
block = Scene.addObject(Cube)
block.worldPosition = [x, y, 0]
block_positions = block_positions.append (pos)

Just need to modify the z height.

My apologies for lack of indents, I’m asking from my phone.

perlin noise is in mathutils

Have you looked at the setVerts() function in my blend in your other recent thread?

Also this: https://docs.blender.org/api/2.78/mathutils.noise.html

Hi mate, yeah I’m poring through the code but it is quite difficult to make sense of for someone who hasn’t done Blender Python before.

import mathutils 
xRange = 100
yRange = 100
for x in range(xRange) :
    for y in range(yRange) :
        Added = own.scene.object('cube', own, 0)
        position = [x, y, 0]
        H =2
        lacunarity =. 5
        octaves = 4
        
        z = mathutils.noise.fractal(position, H, lacunarity, octaves, noise_basis=noise.types.STDPERLIN)
        Added worldPosition= [x, y, z] 
        #untested

I for one would like procedural generation,diggable cube terrain with dynamic terrain loading be included in the logic bricks.