{"tool":"voxel.exec","input":{"code":"// MineBench entry: \"a choo-choo train\".\n// A black steam loco with brass trim, coal tender, three wooden coaches on rails over\n// a ballast embankment and a river bridge, a lit station platform with a brick station\n// house, forest, snowcapped mountains and a smoke plume.\n\nconst TZ = 128;                                       // track centre line (z)\nconst RIV = 60;                                       // river centre line (x)\nconst YARD = { x0: 92, x1: 150, z0: 96, z1: 120 };    // flattened station yard\n\nconst clamp = (v, a, b) => (v < a ? a : v > b ? b : v);\nconst smooth = (a, b, v) => { const t = clamp((v - a) / (b - a), 0, 1); return t * t * (3 - 2 * t); };\nconst pick = (a, b) => a + Math.floor(rng() * (b - a + 1));   // inclusive random integer\n\n// ---------- landscape ----------\nfunction surfaceY(x, z) {\n  const dz = Math.abs(z - TZ);\n  let h = 7 + 4 * Math.sin(x * 0.061 + 1.3) + 3 * Math.sin(z * 0.093 + x * 0.021) + 1.5 * Math.sin((x + 2 * z) * 0.19);\n  // distant mountains only at the far ends of the grid, so the train is never hidden behind a massif\n  h += smooth(95, 125, dz) * (40 + 12 * Math.sin(x * 0.037 + z * 0.05) + 5 * Math.sin(x * 0.11));\n  h = 5 + (h - 5) * smooth(9, 40, dz);                // flat meadow beside the track, so the train reads from any side\n  if (x >= YARD.x0 && x <= YARD.x1 && z >= YARD.z0 && z <= YARD.z1) h = 13;\n  return Math.max(3, Math.round(h));\n}\n\nfunction column(x, z) {\n  const dx = Math.abs(x - RIV);\n  if (dx <= 4) {                                      // river channel\n    block(x, 0, z, 'sand'); block(x, 1, z, 'sand'); block(x, 2, z, 'water');\n    return;\n  }\n  let s = surfaceY(x, z);\n  if (dx <= 6) s = Math.min(s, 4);                    // sandy banks\n  if (s >= 40) {                                      // rock, snowcapped high up\n    box(x, 0, z, x, s - 1, z, 'stone');\n    block(x, s, z, s >= 60 ? 'white_wool' : 'stone');\n  } else {\n    const lo = Math.max(0, s - 3);\n    if (lo > 0) box(x, 0, z, x, lo - 1, z, 'stone');\n    box(x, lo, z, x, s - 1, z, 'dirt');\n    block(x, s, z, dx <= 6 ? 'sand' : 'grass_block');\n  }\n}\n\nfor (let x = 0; x < 256; x++) for (let z = 0; z < 256; z++) column(x, z);\n\n// ---------- track: ballast, sleepers, rails, river bridge ----------\nbox(4, 5, 119, 251, 5, 137, 'cobblestone');\nfor (let x = 4; x <= 251; x += 2) box(x, 6, 122, x, 6, 134, 'oak_planks');\nbox(4, 7, 124, 251, 7, 124, 'iron_block');\nbox(4, 7, 132, 251, 7, 132, 'iron_block');\nbox(57, 0, 122, 58, 4, 134, 'stone_bricks');\nbox(62, 0, 122, 63, 4, 134, 'stone_bricks');\n\n// ---------- station: platform, house, lamps, benches, people ----------\nbox(92, 0, 112, 150, 13, 120, 'stone_bricks');\nbox(92, 13, 120, 150, 13, 120, 'yellow_wool');\nbox(100, 13, 98, 140, 13, 111, 'stone_bricks');\nbox(100, 14, 98, 140, 24, 98, 'bricks');\nbox(100, 14, 99, 100, 24, 111, 'bricks');\nbox(140, 14, 99, 140, 24, 111, 'bricks');\nbox(100, 14, 111, 140, 24, 111, 'bricks');\nfor (let x = 102; x <= 138; x++) {\n  if ((x - 100) % 6 === 0) continue;                  // brick mullions\n  box(x, 17, 111, x, 21, 111, 'glass');\n}\nbox(119, 14, 111, 120, 18, 111, 'brown_wool');        // door\nfor (let k = 0; k < 8; k++) box(97, 25 + k, 97 + k, 143, 25 + k, 112 - k, 'red_wool');\nbox(97, 32, 104, 143, 32, 105, 'gold_block');         // ridge cap\nfor (const bx of [104, 130]) box(bx, 14, 114, bx + 5, 14, 114, 'oak_planks');\nfor (let lx = 96; lx <= 146; lx += 12) {\n  box(lx, 14, 118, lx, 17, 118, 'iron_block');\n  block(lx, 18, 118, 'glowstone');\n}\nfunction person(x, z, shirt) {\n  block(x, 14, z, 'blue_wool'); block(x, 15, z, 'blue_wool');\n  block(x, 16, z, shirt); block(x, 17, z, shirt);\n  block(x, 18, z, 'orange_wool');\n}\nperson(100, 116, 'red_wool');\nperson(103, 112, 'blue_wool');\nperson(121, 116, 'green_wool');\nperson(126, 113, 'orange_wool');\nperson(137, 116, 'yellow_wool');\nperson(145, 113, 'red_wool');\n\n// ---------- locomotive pieces ----------\nfunction wheel(xc, zc) {                              // disc in the x-y plane, centred on a rail\n  for (let x = xc - 4; x <= xc + 4; x++) {\n    for (let y = 7; y <= 15; y++) {\n      const d = Math.hypot(x - xc, y - 11);\n      if (d > 3.5) continue;\n      let m = 'red_wool';\n      if (d <= 2.5) m = 'black_wool';\n      if (d <= 2.5 && (Math.abs(x - xc) < 0.5 || Math.abs(y - 11) < 0.5)) m = 'iron_block';\n      if (d < 0.5) m = 'gold_block';\n      for (let z = zc - 1; z <= zc + 1; z++) block(x, y, z, m);\n    }\n  }\n}\n\nfunction coach(x0, x1) {\n  const mid = Math.floor((x0 + x1) / 2);\n  for (const xc of [x0 + 3, x1 - 3]) { wheel(xc, 124); wheel(xc, 132); }\n  for (let x = x0; x <= x1; x++) {\n    for (let y = 14; y <= 26; y++) {\n      for (let z = 122; z <= 134; z++) {\n        const dz = z - TZ;\n        const outer = (y >= 14 && y <= 20 && Math.abs(dz) <= 6) || (y > 20 && (y - 20) * (y - 20) + dz * dz <= 36);\n        if (!outer) continue;\n        const inner = (y >= 15 && y <= 20 && Math.abs(dz) <= 5) || (y > 20 && (y - 20) * (y - 20) + dz * dz <= 25);\n        const end = x === x0 || x === x1;\n        if (!end && inner) continue;                  // hollow cabin\n        let m = 'oak_planks';\n        if (y === 14) m = 'black_wool';\n        else if (y >= 21) m = 'red_wool';\n        else if (Math.abs(dz) === 6 && y === 20) m = 'gold_block';\n        else if (Math.abs(dz) === 6 && x === mid && y <= 19) m = 'brown_wool';\n        else if (Math.abs(dz) === 6 && y >= 16 && y <= 18 && !end && ((x - x0) % 4 === 1 || (x - x0) % 4 === 2)) m = 'glass';\n        block(x, y, z, m);\n      }\n    }\n  }\n  for (let x = x0 + 2; x <= x1 - 2; x += 3) {         // seats\n    box(x, 15, 125, x + 1, 15, 125, 'red_wool');\n    box(x, 15, 131, x + 1, 15, 131, 'red_wool');\n  }\n  for (let x = x0 + 2; x <= x1 - 2; x += 4) block(x, 21, 128, 'glowstone');\n}\n\n// ---------- engine: boiler, cab, smokebox, chimney, cowcatcher ----------\nfor (const xc of [180, 187, 194]) { wheel(xc, 124); wheel(xc, 132); }\nbox(180, 11, 122, 194, 11, 122, 'iron_block');        // side rods\nbox(180, 11, 134, 194, 11, 134, 'iron_block');\nbox(176, 14, 126, 198, 15, 130, 'iron_block');        // frame\n\nfor (let x = 176; x <= 198; x++) {                    // boiler: a cylinder along x\n  for (let y = 15; y <= 25; y++) {\n    for (let z = 123; z <= 133; z++) {\n      const r = Math.hypot(y - 20, z - TZ);\n      if (r > 5) continue;\n      let m = 'black_wool';\n      if (y - 20 >= 3 && r >= 3.8) m = 'gray_wool';   // sheen along the top\n      if ((x === 178 || x === 194) && r >= 4) m = 'gold_block';\n      if (x >= 197) m = 'iron_block';                 // smokebox\n      block(x, y, z, m);\n    }\n  }\n}\nfor (let y = 15; y <= 25; y++) {                      // smokebox door\n  for (let z = 123; z <= 133; z++) {\n    if (Math.hypot(y - 20, z - TZ) <= 4.5) block(199, y, z, 'iron_block');\n  }\n}\nbox(200, 19, 127, 201, 21, 129, 'glowstone');         // headlamp\n\nfor (let y = 8; y <= 12; y++) {                       // cowcatcher bars\n  for (let z = 122; z <= 134; z += 2) {\n    for (let x = 199; x <= 203 - (y - 8); x++) block(x, y, z, 'iron_block');\n  }\n}\n\nbox(175, 21, 123, 187, 25, 133, 'black_wool');        // cab deck\nbox(175, 26, 123, 187, 33, 123, 'black_wool');        // cab sides\nbox(175, 26, 133, 187, 33, 133, 'black_wool');\nbox(175, 26, 124, 175, 33, 132, 'black_wool');        // cab back\nbox(177, 27, 123, 184, 31, 123, 'glass');\nbox(177, 27, 133, 184, 31, 133, 'glass');\nbox(175, 27, 126, 175, 31, 130, 'glass');\nbox(174, 34, 122, 188, 34, 134, 'red_wool');          // cab roof\nbox(174, 15, 123, 175, 22, 133, 'black_wool');        // engine apron\n\nbox(189, 26, 126, 191, 26, 130, 'gold_block');        // steam dome\nbox(190, 27, 127, 190, 27, 129, 'gold_block');\n\nbox(193, 25, 126, 195, 30, 130, 'black_wool');        // chimney\nbox(192, 31, 125, 196, 31, 131, 'iron_block');        // flared top\nbox(193, 32, 126, 195, 32, 130, 'black_wool');\n\n// ---------- tender and coaches ----------\nbox(158, 15, 123, 173, 22, 133, 'black_wool');\nbox(160, 23, 124, 171, 23, 132, 'cobblestone');       // coal\nbox(158, 18, 123, 173, 18, 123, 'gold_block');\nbox(158, 18, 133, 173, 18, 133, 'gold_block');\nfor (const xc of [160, 167]) { wheel(xc, 124); wheel(xc, 132); }\n\ncoach(137, 155);\ncoach(115, 133);\ncoach(93, 111);\n\nbox(156, 12, 127, 157, 13, 129, 'iron_block');         // couplers\nbox(134, 12, 127, 136, 13, 129, 'iron_block');\nbox(112, 12, 127, 114, 13, 129, 'iron_block');\n\n// ---------- forest ----------\nfunction tree(x, s, z, h) {\n  for (let y = s + 1; y <= s + h; y++) block(x, y, z, 'oak_log');\n  const cy = s + h + 1;\n  const r = 2.6 + rng() * 1.2;\n  for (let dx = -4; dx <= 4; dx++) {\n    for (let dy = -3; dy <= 3; dy++) {\n      for (let dz = -4; dz <= 4; dz++) {\n        const d = dx * dx + dy * dy * 1.2 + dz * dz;\n        if (d > r * r + rng() * 2 - 1) continue;\n        if (dx === 0 && dz === 0 && dy <= 0) continue;   // keep the trunk visible\n        block(x + dx, cy + dy, z + dz, 'oak_leaves');\n      }\n    }\n  }\n}\n// telegraph poles along the far side of the track, with cross-arms\nfor (let x = 10; x <= 246; x += 16) {\n  const s = surfaceY(x, 141);\n  box(x, s + 1, 141, x, s + 9, 141, 'oak_planks');\n  box(x - 2, s + 8, 141, x + 2, s + 8, 141, 'oak_planks');\n}\n// two signal posts at the station ends\nfor (const sx of [84, 158]) {\n  box(sx, 6, 138, sx, 13, 138, 'iron_block');\n  block(sx, 14, 138, 'red_wool'); block(sx, 15, 138, 'green_wool');\n}\n\nlet trees = 0;\nfor (let i = 0; i < 1200 && trees < 90; i++) {\n  const x = pick(6, 249), z = pick(6, 249);\n  if (Math.abs(z - TZ) <= 13) continue;\n  if (Math.abs(x - RIV) <= 9) continue;\n  if (x >= 86 && x <= 156 && z <= 124) continue;\n  const s = surfaceY(x, z);\n  if (s < 6 || s >= 40) continue;\n  tree(x, s, z, pick(4, 6));\n  trees++;\n}\n\n// ---------- smoke plume trailing back from the chimney ----------\nfunction puff(cx, cy, cz, r) {\n  for (let x = Math.floor(cx - r); x <= Math.ceil(cx + r); x++) {\n    for (let y = Math.floor(cy - r); y <= Math.ceil(cy + r); y++) {\n      for (let z = Math.floor(cz - r); z <= Math.ceil(cz + r); z++) {\n        const d = (x - cx) * (x - cx) + (y - cy) * (y - cy) + (z - cz) * (z - cz);\n        if (d > r * r * (0.85 + rng() * 0.3)) continue;\n        block(x, y, z, (y < cy - r * 0.3 && rng() < 0.5) ? 'gray_wool' : 'white_wool');\n      }\n    }\n  }\n}\nfor (let k = 0; k < 12; k++) puff(194 - 2.6 * k, 34 + 1.5 * k, 128 + 1.8 * Math.sin(k * 1.1), 2.1 + 0.42 * k);\n","gridSize":256,"palette":"simple","seed":123}}