Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active August 21, 2021 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/d8ac5aa2664b934435492ccb434d30b0 to your computer and use it in GitHub Desktop.
Save YonatanKra/d8ac5aa2664b934435492ccb434d30b0 to your computer and use it in GitHub Desktop.
function diamondSquare(matrix) {
let chunkSize = MATRIX_LENGTH - 1;
let randomFactor = RANDOM_INITIAL_RANGE;
while (chunkSize > 1) {
calculateSquare(matrix, chunkSize, randomFactor)
calculateDiamond(matrix, chunkSize, randomFactor)
chunkSize /= 2;
randomFactor /= 2;
}
return matrix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment