just 4 tiles
Log in to post a comment.
const SZ = 17; // min=10, max=40, step=1 const cell = 200 / SZ Canvas.setpenopacity(-1); const t = new Turtle(); for (let y = 0; y < SZ; y++) { for (let x = 0; x < SZ; x++) { let tile = Math.floor(4 * Math.random()) if (tile == 0) { t.jump(-100 + (x + 0.5) * cell, -100 + y * cell) t.setheading(90) t.circle(cell/2, 90) t.jump(-100 + (x + 0.5) * cell, -100 + (y + 1) * cell) t.setheading(-90) t.circle(cell/2, 90) } else if (tile == 1) { t.jump(-100 + (x + 0.5) * cell, -100 + y * cell) t.setheading(-90) t.circle(cell/2, -90) t.jump(-100 + (x + 0.5) * cell, -100 + (y + 1) * cell) t.setheading(90) t.circle(cell/2, -90) } else if (tile == 2) { let gap = cell / 3 t.jump(-100 + (x + 0.5) * cell, -100 + y * cell) t.setheading(90) t.forward(cell / 2 - gap / 2) t.penup() t.forward(gap) t.pendown() t.forward(cell / 2 - gap / 2) t.jump(-100 + x * cell, -100 + (y + 0.5) * cell) t.goto(-100 + (x + 1) * cell, -100 + (y + 0.5) * cell) } else { let gap = cell / 3 t.jump(-100 + x * cell, -100 + (y + 0.5) * cell) t.setheading(0) t.forward(cell / 2 - gap / 2) t.penup() t.forward(gap) t.pendown() t.forward(cell / 2 - gap / 2) t.jump(-100 + (x + 0.5) * cell, -100 + y * cell) t.goto(-100 + (x + 0.5) * cell, -100 + (y + 1) * cell) } } }