Skip to content

Instantly share code, notes, and snippets.

@bazzargh
bazzargh / circles.js
Last active April 12, 2025 22:40
"place specimens on the grid at randomly selected points until no more can be placed: "no more" because each specimen has a neighborhood radius r_i such that no other specimens may be placed within that radius."
function initialiseGrid(w, h) {
// first get all the initial max radii
let temp = []
for (let x = 0; x < w; x++) {
for (let y = 0; y < h; y++) {
let k = JSON.stringify([x, y])
temp.push([k, Math.min(x, y, w-x, h-y)])
}
}
// now shuffle, so that we do not need to filter