Numbers with decimal places are floating. Do you want whole numbers? If so, use integers.
Second, your code shows several variable names inside your Function (i.e. build_patternSize, mapWidth, mapHeight, etc). Are these variables global? If not, then they are zero-value inside the Function.
Second, your code shows several variable names inside your Function (i.e. build_patternSize, mapWidth, mapHeight, etc). Are these variables global? If not, then they are zero-value inside the Function.